Tip 1 : Try to have a firm base on the basics.
Tip 2 : Practice good questions not waste time on the easy questions.
Tip 3 : Try at least to have 2-3 projects with latest Tech stack used.
Tip 4 : If you have free time start practicing puzzles.
Tip 1 : One Page Resume, Do not put false things in a resume.
Tip 2 : Mention 2 -3 projects



Each pair should be sorted i.e the first value should be less than or equals to the second value.
Return the list of pairs sorted in non-decreasing order of their first value. In case if two pairs have the same first value, the pair with a smaller second value should come first.



In the above image, areas in green, red, and violet color are all submatrices of the original 4x4 matrix.
1. Binary valued matrix has only two values in each cell : 0 and 1.
2. A submatrix is a matrix formed by selecting certain rows and columns from a larger matrix.
3. The area of a matrix with 'h' rows and 'w' columns is equal to 'h' * 'w'.
I have used the dyanmic programming to solve this problem here is a quick approach
1) Construct a sum matrix S[R][C] for the given M[R][C].
a) Copy first row and first columns as it is from M[][] to S[][]
b) For other entries, use following expressions to construct S[][]
If M[i][j] is 1 then
S[i][j] = min(S[i][j-1], S[i-1][j], S[i-1][j-1]) + 1
Else /*If M[i][j] is 0*/
S[i][j] = 0
2) Find the maximum entry in S[R][C]
3) Using the value and coordinates of maximum entry in S[i], print
sub-matrix of M[][]



INTUITION :
When you are at a cell, you have to option to go, either right or down(if possible). So we have to explore at each step, that in how many ways we can reach to (m-1, n-1) cell from that given cell.



For ‘N’ = 6 and ‘EDGES’ = [ [0,1], [0, 2], [2, 3], [2, 4], [2, 5] ], see the below picture for reference:

1. For node 0:
a. Distance from node 0 to node 1 is 1.
b. Distance from node 0 to node 2 is 1.
c. Distance from node 0 to node 3 is 2.
d. Distance from node 0 to node 4 is 2.
e. Distance from node 0 to node 5 is 2.
So the sum of all the distances is 8.
2. For node 1:
a. Distance from node 1 to node 0 is 1.
b. Distance from node 1 to node 2 is 2.
c. Distance from node 1 to node 3 is 3.
d. Distance from node 1 to node 4 is 3.
e. Distance from node 1 to node 5 is 3.
So the sum of all the distances is 12.
3. For node 2:
a. Distance from node 2 to node 0 is 1.
b. Distance from node 2 to node 1 is 2.
c. Distance from node 2 to node 3 is 1.
d. Distance from node 2 to node 4 is 1.
e. Distance from node 2 to node 5 is 1.
So the sum of all the distances is 6.
4. For node 3:
a. Distance from node 3 to node 0 is 2.
b. Distance from node 3 to node 1 is 3.
c. Distance from node 3 to node 2 is 1.
d. Distance from node 3 to node 4 is 2.
e. Distance from node 3 to node 5 is 2.
So the sum of all the distances is 6.
5. For node 4:
a. Distance from node 4 to node 0 is 2.
b. Distance from node 4 to node 1 is 3.
c. Distance from node 4 to node 2 is 1.
d. Distance from node 4 to node 3 is 2.
e. Distance from node 4 to node 5 is 2.
So the sum of all the distances is 6.
6. For node 5:
a. Distance from node 5 to node 0 is 2.
b. Distance from node 5 to node 1 is 3.
c. Distance from node 5 to node 2 is 1.
d. Distance from node 5 to node 3 is 2.
e. Distance from node 5 to node 4 is 2.
So the sum of all the distances is 6.
So, ‘ANS’ for the above example will be [8, 12, 6, 10, 10, 10].
The simplest approach to solve the given problem is to perform the Depth First Search Traversal from every node and find the sum of distance every other node from the current source node. After checking from all the nodes as the source node print the maximum sum among all the sum of values obtained.
After we can optimised the above proposed solution.
Technical Interview



If the given array is [1,2,3] then the answer would be 2. One of the ways to make all the elements of the given array equal is by adding 1 to the array element with value 1 and subtracting 1 from the array element with value 3. So that final array would become [2,2,2].
Managerial cum HR



I have used hashing to achieve the average time complexity as O(n) for many cases.
1) Initialize count as 0.
2) Insert all distinct elements of arr[] in a hash map. While inserting,
ignore an element if already present in the hash map.
3) Do following for each element arr[i].
a) Look for arr[i] + k in the hash map, if found then increment count.
b) Look for arr[i] - k in the hash map, if found then increment count.
c) Remove arr[i] from hash table.
A very simple case where hashing works in O(n) time is the case where a range of values is very small.

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?