Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike

1 Answer

0 like 0 dislike
Rcently had a coderpad with Goldman sachs.
Attened Round 1:
Question 1: FIle contains list of Ip Address. Get the IP address/s with highest frequency. If multiple Ip address available with higest freq, return sorted comma separeted.
Approch : Create TreeMap instead of Hashmap (for sorted IP address), get the min freq, get the Ip address with the min freq.

Ques2 : Trapping rain water
Approch :
get the left wall,
get the right wall
if if left wall is smaller, check the left value and move the left pointer
if right wall is smaller, check the right value and move the right pointer

public int trap(int[] a) {
    int l = 0, r = a.length-1;
    int lMax = Integer.MIN_VALUE, rMax = Integer.MIN_VALUE;
    int total = 0;
    while(l < r){
        if(lMax < a[l]){
            lMax = a[l];
        if(rMax < a[r]){
            rMax = a[r];
        if(lMax <= rMax){    
            total = total + lMax-a[l];
            total = total + rMax-a[r];
    return total;

YOE - 1.5yrs
by Expert (30,360 points)