Tip 1 : Good Knowledge of Time and Space Complexity
Tip 2 : Practice DSA Questions
Tip 1 : Have some projects on your resume.
Tip 2 : Do not put false things on your resume.
Timing - It was an online assessment, and can be given at any time based on your convenience in under 1 week's time.
Environment - Hackerrank provides indentation and hints for keywords in any language you choose like C, C++ , Java



The given linked lists may or may not be null.
If the first list is: 1 -> 4 -> 5 -> NULL and the second list is: 2 -> 3 -> 5 -> NULL
The final list would be: 1 -> 2 -> 3 -> 4 -> 5 -> 5 -> NULL
Step 1) Initialize result list as empty: head = NULL.
Step 2) Let 'a' and 'b' be the heads of first and second list respectively.
Step 3) Reverse both the lists.
Step 4) While (a != NULL and b != NULL)
a) Find the larger of two (Current 'a' and 'b')
b) Insert the larger value of node at the front of result list.
c) Move ahead in the list of larger node.
Step 5) If 'b' becomes NULL before 'a', insert all nodes of 'a' into result list at the beginning.
Step 6) If 'a' becomes NULL before 'b', insert all nodes of 'b' into result list at the beginning.



1. You can return the list of values in any order. For example, if a valid triplet is {1, 2, -3}, then {2, -3, 1}, {-3, 2, 1} etc is also valid triplet. Also, the ordering of different triplets can be random i.e if there are more than one valid triplets, you can return them in any order.
2. The elements in the array need not be distinct.
3. If no such triplet is present in the array, then return an empty list, and the output printed for such a test case will be "-1".
Step 1) Traverse the array from start to end. (loop counter i)
Step 2) Create a HashMap or set to store unique pairs.
Step 3) Run another loop from i+1 to end of the array. (loop counter j)
Step 4) If there is an element in the set which is equal to x- arr[i] – arr[j], then print the triplet (arr[i],arr[j],x-arr[i]-arr[j]) and break
Step 5) Insert the jth element in the set.
The interviewer was SDE – 2 at Amazon.
Timing - Afternoon 5:00 PM



Let an array ‘arr’ = [2,2,1,1].
In this example, the array can be split like this [2,2], [1,1] in this
case the first and last occurrence of 2 lies in a first subarray and
similarly first and the last occurrence of 1 lies in a second
subarray.
The key idea in this problem is storing the first and last occurrence index of every element. So, we can store the first and last index and then iterate over the array, and in each iteration, we check if the maximum index of the last occurrence of all the previous elements of the current subarray is less than or equal to the current index.
We use array hash to store the last occurrence of an element.



You may assume that given ‘X’ and ‘Y’ definitely exist in the given binary tree.
For the given binary tree

LCA of ‘X’ and ‘Y’ is highlighted in yellow colour.
Step 1) Find a path from the root to n1 and store it in a vector or array.
Step 2) Find a path from the root to n2 and store it in another vector or array.
Step 3) Traverse both paths till the values in arrays are the same. Return the common element just before the mismatch.
The interviewer was the Engineering Manager at Amazon
1) Tell me about a time that you failed at work
2) Tell me how you deal with ambiguity
3) Tell me about the most complex problem you have worked on
Tip 1 : Answer in STAR Method
Tip 2 : Don't say false things
Tip 3 : Always relate your answer along with some examples of previous experience
Tip 4 : Emphasize on the 16 leadership principles of Amazon

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?