Tip 1 : Practice at least 10-20 questions of DS & Also on each topic from difficulty level easy to hard.
Tip 2 : Prepare well around OOPs concepts and Database concepts.
Tip 3 : If you have 2.5+ year of experience practice around HLD and LLD.
Tip 1 : Please mention the keyword related to the work that you have done. (eg. Git, Maven, JUnit, Java, AWS )
Tip 2 : Please mention any certification that you have done. And try to keep your resume within one page.
This round was the online coderpad round. This round was based on easy and medium level DS and Algo based problems.
I was able to solve the problems in optimised way.



Paragraph = ‘It's a square SqUare. It's a FLAT flat.’
Banned =[FLAT, IT, S].
So we can see these words [IT, S, SQUARE, FLAT ] are most frequent.
Now we will look at to banned list and we can see 3 of the words are banned.
So we have a unique answer SQUARE which has a frequency of 2 and not on the banned list.
I gave the Hashmap bases solution.
static char getMaxOccurringChar(String str)
{
// Create array to keep the count of individual
// characters and initialize the array as 0
int count[] = new int[ASCII_SIZE];
// Construct character count array from the input
// string.
int len = str.length();
for (int i=0; i count[str.charAt(i)]++;
int max = -1; // Initialize max count
char result = ' '; // Initialize result
// Traversing through the string and maintaining
// the count of each character
for (int i = 0; i < len; i++) {
if (max < count[str.charAt(i)]) {
max = count[str.charAt(i)];
result = str.charAt(i);
}
}
return result;
}



1)The amount of petrol that is available at this particular petrol pump.
2)The distance to reach the next petrol pump.
public int canCompleteCircuit(int[] gas, int[] cost) {
int sumGas = 0;
int sumCost = 0;
int index = 0;
int rem = 0;
for(int i=0; i sumGas+= gas[i];
sumCost += cost[i];
rem+= gas[i];
rem -= cost[i];
if(rem < 0){
rem = 0;
index = i+1;
}
}
if(sumGas < sumCost ) return -1;
return index;
}
HR called for the interview availability. This round was set up during day time. This round was elimination round and based on DS and Algorithm problem.Overall the interview experience was really great. I was able to provide optimised solution for both DS Algo problem.



A subsequence is a sequence that can be derived from another sequence by deleting zero or more elements without changing the order of the remaining elements.
Step1: I solved the problem using the recursion
Step2: Interviewer asked me to optimise
Step: Then I solution using dynamic programming approach since I have already solved this problem on leetcode:
public int lengthOfLIS(int[] nums) {
int n = nums.length;
int[]LIS = new int[n];
int ans = Integer.MIN_VALUE;
for(int i = n-1; i>=0; i--){
int tempAns = 1;
for(int j = i+1; j nums[i]){
tempAns = Math.max(tempAns, 1+LIS[j]);
}
}
LIS[i] = tempAns;
ans = Math.max(ans, tempAns);
}
return ans;
}



The width of each bar is the same and is equal to 1.
Input: ‘n’ = 6, ‘arr’ = [3, 0, 0, 2, 0, 4].
Output: 10
Explanation: Refer to the image for better comprehension:

You don't need to print anything. It has already been taken care of. Just implement the given function.
Step1: First I solved the problem with brute force approach by checking for each element max element in it's left and right and then calculating the water contained at that particular position.
Step2: Interviewer asked me to optimise the solution, So gave the solution by storing the left and right max in extra array and calculating the water contained live below:
public int trap(int[] height) {
int n = height.length;
int left[] = new int[n];
left[0] = 0;
for(int i=1; i=0; i--){
right[i] = Math.max(right[i+1], height[i+1]);
}
int ans = 0;
for(int i=0; i 0) ans+= temp;
}
return ans;
}
HR called for the interview availability. This round was set up during day time. This round was elimination round and based on DS and Algorithm problem.Overall the interview experience was really great but I wasn't selected in this round.



‘N’ = 4, ‘K’ = 2
‘ARR’ = [1, 1, 2, 3]
There are ‘3’ subarrays with ‘2’ distinct elements, which are as follows: [1, 2], [2, 3], [1, 1, 2].
Thus, you should return ‘3’ as the answer.
Step1: I gave the brute force approach for this problem. Including the solution below:
public int subarraysWithKDistinct(int[] nums, int k) {
Map map = new HashMap();
int ans = 0;
int i=0; int j=0;
while(j < nums.length){
// add the element in the map
map.put(nums[j], map.getOrDefault(nums[j], 0) + 1);
//window size greater than k then remove or update the freq of element in the map
while(map.size() > k){
map.put(nums[i], map.get(nums[i])-1);
if(map.get(nums[i]) == 0) map.remove(nums[i]);
i++;
}
if(map.size() == k ){
Map tempMap = new HashMap(map);
int start = i;
while(tempMap.size() == k ){
ans++;
tempMap.put(nums[start], tempMap.get(nums[start])-1);
if(tempMap.get(nums[start]) == 0) tempMap.remove(nums[start]);
start++;
}
}
j++;
}
return ans;
}
Step2: Interviewer asked me to optimise the solution and I couldn't provide the optimised solution.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?