第一轮dsa
import java.util.arraylist;
import java.util.list;
public class birlapivot {
/* software engineer 1 role: interview 1 :
/
/given a array=[3,4,9,7,8,9,13,5] and sum=12 , i need to find the all the sub arrays which array elements should be splitted in array*/
/* time : o(n* max(arr)%sum) , space : o(n* max(arr)%sum)*/
public list<list>> findsubarrayssplittinginputarrayequaltosum(int[] arr, int sum){
list<list>> ans=new arraylist();
int i=0;
while(i<arr.length int num="arr[i]," s="sum;" for j="0;i<num/sum;i++){" list> subarr=new arraylist();
subarr.add(sum);
ans.add(subarr);
}
int rem=num%sum;
if(s==sum){
list<integer> subarr=new arraylist();
subarr.add(sum);
ans.add(subarr);
}
i++;
}
return ans;
}
/*given an array find the max of two numbers difference provided the left --> right, right should be maximum */
/*time :o(n^2) space :o(1)*/
public int findmaxdifflefttoright(int[] arr){
int max=0;
for(int i=0;i<arr.length for j="i+1;j<arr.length;j++){" if> arr[i]){
max=math.max(arr[i]-arr[j],max);
}
}
}
return max;
}
/*follow-up : can we decrease the time complexity : solution : yes, we can construct post-max array for every element */
/*time : o(n) space :o(n)*/
public int findmaxdifflefttorightpostmaxarray(int [] arr){
int max=0;
int[] postmaxarr=new int[arr.length];
postmaxarr[arr.length-1]=0;
for(int i=arr.length-2; i>=0; i--){
postmaxarr[i]=math.max(postmaxarr[i+1], arr[i]);
}
for(int i=0; i<arr.length i max="math.max(postmaxarr[i]" arr return : can we decrease space complexity y solution yes since are using only one element at a time use single variable instead of array :o public int findmaxdifflefttorightspaceoptimized for>=0; i--){
postmaxele=math.max(postmaxele, arr[i]);
max = math.max(postmaxele- arr[i], max);
}
return max;
}
}
</arr.length></arr.length></arr.length>登录后复制
第二轮系统设计
public class BirlaR2SysDesign {
/* [ 15/May/2024 ::
Question 1: DSA Time : O(n^2) Space :O(n)
- Question 1 ---> Array = [4,5,900,11,15]
Sum = 12- 900 % 12
Sub arrays : { {4,5,3} , {12} ..., {6,6}, {5,7}, {8}}
- 900 % 12
Question 2: Design Kafka,RabbitMQ, GCP Pub Sub System :
*
* { topics --> { id, name} , Subscribers--- { id, name, topiId} , messages --{ topicId , scid, msg , status (process/not prosed/ purged) ,
* rtryCount, endpoint, timeStamp, lastModified } }
*
* select sub.id from Subscribers where topic= id , message,;
*
* indexing --> queries [ indexCount, timestamp, status ]
* binarySearch
*
* while(){
* // [200, 500 ]
* [(select * message where status= notProces & retryCount collections
* .stream()
* .parallel()
* .map( msg -> perform(msg))
*
* @Async
* perform{
* if(REST --> HTTP:200;)
* status= processed;
* else {
* retryCount++;
* }
* }
* }
*
Question 3 : some sql questions
* transaction
* begin:
* save point) delete -> empId=1;
* save point) update --> empId=1
* end
* commit
*
* locking:
Question 4 : some spring boot questions
* all : @controller, @RestController, @Get, @post ,@Put @Delete
* @Repository, @Service,
* @Configuration, @Component
* @Bean
* @SpringApplication--> @Autoconfig( )
*
* @CustomAnnotations{}
*
* @Transactional()
*
* s.a..........h.i.@gmail.com --> all dots; @Annotations
*
* step-way , rollback , commit,
* queue = []
*
12.5 , 11
*/
}
登录后复制
结果:
已选择
以上就是Birla Pivot SDE-面试经历 (4)的详细内容,更多请关注php中文网其它相关文章!
91资源网站长-冰晨2024-08-27 17:15
发表在:【账号直充】爱奇艺黄金VIP会员『1个月』官方直充丨立即到账丨24小时全天秒单!不错不错,价格比官方便宜
91资源网站长-冰晨2024-08-27 16:15
发表在:2022零基础Java入门视频课程不错,学习一下