登录
首页 >  文章 >  java教程

Birla Pivot SDE-面试经历 (4)

来源:dev.to

时间:2024-07-25 08:34:33 462浏览 收藏

哈喽!大家好,很高兴又见面了,我是golang学习网的一名作者,今天由我给大家带来一篇《Birla Pivot SDE-面试经历 (4)》,本文主要会讲到等等知识点,希望大家一起学习进步,也欢迎大家关注、点赞、收藏、转发! 下面就一起来看看吧!

image description

第一轮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<integer>> findsubarrayssplittinginputarrayequaltosum(int[] arr, int sum){
        list<list<integer>> ans=new arraylist<>();
        int i=0;
        while(i<arr.length){
                int num=arr[i], s=sum;
                for(int j=0;i<num/sum;i++){
                    list<integer> 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;i++){
            for(int j=i+1;j<arr.length;j++){
                if(arr[j] > 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[i], max);
        }
        return max;
    }


    /*follow-up : can we decrease space complexity y : solution yes, since we are using only one element at  a time we can use a single variable instead of array*/
   /*time :o(n) space :o(1)*/
    public int findmaxdifflefttorightspaceoptimized(int[] arr){
        int max=0 ,postmaxele=0;
        for(int i=arr.length-2; i>=0; i--){
            postmaxele=math.max(postmaxele, arr[i]);
            max = math.max(postmaxele- arr[i], max);
        }
        return max;
    }
}

第二轮系统设计

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}}


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 < threshold && timestamp < msg.timeStamp + 4days; )] --> 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)》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布文章相关知识,快来关注吧!

声明:本文转载于:dev.to 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>