Tip 1 : Practice all previous amazon interview questions
Tip 2 : Study Well about your projects about databases used and the reason they are used.
Tip 1 : Well defined projects in resume
Tip 2 : Problem solving/Open source skills are a plus
Online Coding Round



Up: (x, y) -> (x - 1, y)
Left: (x, y) -> (x, y - 1)
Down: (x, y) -> (x + 1, y)
Right: (x, y) -> (x, y + 1)
consider the binary matrix below. If source = (0, 0) and destination = (3, 4), the shortest path from source to destination has length 11.

Step 1 -> Start a BFS from the given source point
Step 2 -> Maintain a counter variable which holds the value of the level of BFS which is being investigated
Step 3-> When you reach the target cell point return the value of counter variable which will denote the shortest distance.
Step 4-> If target is not reached return -1 in the end after the BFS is completed



Step 1 -> Declare a Min Heap and push all the given rope lengths in it.
Step 2 -> Execute till the size of the Min Heap is greater than 2.
Step 3 -> At each step take the top most two entries from the Min Heap and add them to your cost.
Step 4 -> Also add the two min entries taken at some point back to Min heap as two ropes of size x and y when joined together creates a new rope of size x+y which can be used further.
Step 5 -> As it is a greedy approach using Min Heap , the total cost in minimized.
Problem Solving and Data Structures round.



Anagrams are defined as words or names that can be formed by rearranging the letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "rasp" are anagrams.
'triangle' and 'integral'
'listen' and 'silent'
Since it is a binary problem, there is no partial marking. Marks will only be awarded if you get all the test cases correct.
Step 1-> Run two nested for loops to check for each pair (arr[i],arr[j]) are anagrams of each other or not.
Step 2-> For checking anagrams I used hashing where I counted frequency of each character if all the frequencies were same in both the string return true else return false that they are not anagrams.
Step 3 -> Grouped the pairs which matched that they are anagrams.
Extended Problem Solution:
When all the characters in each string were unique (not repeating)
Step 1 -> Try to think each word to be encoded as Binary.
Step 2 -> Say a string "abe" will look something like "00000000000000000000010011" where LSB to MSB tells us if 0th character , 1st character and so on appears or not. Note that it is 26 bit Binary Number as strings are given to have only lower case character.
Step 3-> Encode given strings into binary number and group all the strings who get the same encoding which can be further done using hashing.



A pair ('ARR[i]', 'ARR[j]') is said to be an inversion when:
1. 'ARR[i] > 'ARR[j]'
2. 'i' < 'j'
Where 'i' and 'j' denote the indices ranging from [0, 'N').
First I gave a Brute force solution using two nested Loops and trying out all pairs, which Interviewer asked me to optimize.
I asked about the constraints of elements occurring in the array , it was given that each arr[i]<=10^5
Step 1 -> Declare a Binary Indexed Tree of size equal to maximum element occurring in array
Step 2- > Traverse array from end till start (N-1 index till 0) and at each step if the element currently is x , find prefix sum of BIT Tree till index x which will tell the number of smaller elements smaller than arr[i] in the right of it ( which exactly is the meaning of inversions).
Step 3 -> return the count of inversions at end.
Another Solution when arr[i]<=10^9
Using Merge Sort to count Inversions
DSA and Problem Solving



For the given string “CodingNinjas”: “Ninja” is a substring while “dinas” is a subsequence.
Step 1 -> Gave a Brute force solution by trying out all substrings and building a check function to verify if current window has all characters of other string or not.
Step 2-> I was told to optimize it
Step 3-> Tried using hashing + sliding window
Step 4 -> was not able to code it up properly.
Step 5 -> Tried doing it using Binary search where start=Length of String B and end= String length of A and tried each substring of the chosed length ( mid=(start+end/2)).
Step 6 -> was an overkill for the problem so Interviewer wanted me to focus on hashing + sliding window
Deep discussions about projects about the tech stack used and why it is used . In depth subject questions .
What is LRU cache and how it is implemented.?
Tip 1 : For such questions , you can't come up with the best solution during an interview try to give two three iterations of practice of coding/understanding during preparation.
Tip 2 : Try to make small notes for fast revision.
Difference between NOSQL and SQL DataBases , in what scenario we should used SQL and NoSQL?
Tip 1 : Have a good understanding of projects implemented and the choice of data base for the problem you are solving.
Tip 2 : Make notes for quick revision.
What are semaphores , What are mutexes , explain difference between them, What is multithreading , explain a scenario where you may need multithreading?

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?