Tip 1 : Read last year interview experiences of the company you apply for.
Tip 2 : In the last 2-3 days before your interview, just revise your concepts and problems.
Tip 1 : Keep it simple and clean. Don't make it flashy.
Tip 2 : Highlight your experiences and projects.
It was strictly a DSA round where 2 coding problems asked from me.



The distance is calculated as |i1 – i2| + |j1 – j2|, where i1, j1 are the coordinates of the current cell and i2, j2 are the coordinates of the nearest cell having value 1.
You can only move in four directions which are : Up, Down, Left and Right.
If N = 3, M = 4
and mat[ ][ ] = { 0, 0, 0, 1,
0, 0, 1, 1,
0, 1, 1, 0 }
then the output matrix will be
3 2 1 0
2 1 0 0
1 0 0 1
The better approach is to do a BFS starting from all the 1s in the given matrix. The distance of all the 1s is zero and for all the adjacent the minimum distance is one more than this.
Create a queue of Coordinates, that is used to store the (row, column) of an element. Create an array ans of size same as array matrix.
Traverse through all the elements of the matrix and push the coordinates of elements that are 1 into the queue.
Initialize a variable minDistance as 0. While queue is not empty repeat steps 4 and 5.
Initialize a variable size as size of the queue. Run a loop for i equals 0 to size(not included). At every iteration pop out an element from the queue. Set ans[row][col] as minDistance, and enqueue all the valid adjacents of this element that are 0 in the matrix array and set them as 1 in the matrix array.
Increment minDistance.
Print the ans array.



A subarray is a slice from a contiguous array (i.e., occupy consecutive positions) and inherently maintains the order of elements.
We use a vector of unordered_maps for our dynamic programming.
The vector is used as follows: [ index, {diff, count} ].
For each index, we have all common differences and count arithmetic slices up to that index.
We iterate through the given vector nums, and for each number we iterate again from the beginning to there.
diff is the difference, so we can add 1 to the counter of dp[i][diff].
If we already have a key for diff in dp[j], we can add to dp[i][diff] all the count that we had by dp[j][diff]. And that's what we add to our res.
Again it was a DSA round.



If the matrix is
0 2 4 1
4 8 3 7
2 3 6 2
9 7 8 3
1 5 9 4
Then answer is 47. As, Alice will collect coins 0+8+3+9+1 = 21 coins. Bob will collect coins 1+7+6+8+4 = 26 coins. Total coins is 21+26 = 47 coins.
Since we want to maximum the value we can get, and we always get the middle value of three selection.
We can first sort piles and take 3 coins [Li, Mi, Hi] in following manners.
n=9
piles = [L1,L2,L3,M2,H3,M2,H3]
As this kind of greedy approach, we can maximize the number of coins we can have.
time: O(nlogn)
space: O(1)

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?