Tip 1 : Practice a lot.
Tip 2 : Focus on system design
Tip 3 : Focus on amazon Leadership principles.
Tip 1: Mention relevant details for job you are applying.
Tip 2: Be objective and concise.
I used DFS to find number of distinct components.
1. When N is odd consider the middle element to be part of 1st half.
2. The sum should not contain any leading zero, except the number 0 itself.
Given Linked List: 1-2-3-4-5-5-6
First half: 1-2-3-4
Second half: 5-5-6
Output Linked List: 1-7-9-0 = (1234 + 556 = 1790)
Can you add both halves without finding the length of Linked List and in O(1) space?
If the given array is [1, 3, 2], then you need to return [3, -1, -1]. Because for 1, 3 is the next greater element, for 3 it does not have any greater number to its right, and similarly for 2.
Solved using stack.
The same word from a dictionary can be used as many times as possible to make sentences.
Paraphrasing the solution in my words
Let's take an example. s="catsand" and wordDict = ["cat", "cats", "and", "sand"].
The solution starts by taking the string S( "catsand") initially finding whether whole string is present or not . IN this case it is not present in the dict.
Now breaking the string and then finding
s.substr( i) gives the substring from ith index till the end. so string word goes as
atsand // not present
tsand // not present
sand //present then the remainder is calculated which is cat in this case and recursive function is called and same thing is done with cat which will return cat and also store the result in the unordered map . Now comes the combine part where both the string are combined and the pushed in the result " cat sand".
and // then comes and which is present so now again wordbreak called on remainder which is cats now and this will return cats. Now both strings are combined and inserted into result . result = {. "cat sand", "cats and"}; Now after the loop ending the result is returned and also stored in map.
'S' = "{}()".
There is always an opening brace before a closing brace i.e. '{' before '}', '(' before ').
So the 'S' is Balanced.
Used the stack approach.
Design a local transport system like BMTC.
It was mix of HLD, LLD design discussion of your project. Make sure you know enough about your projects. Questions asked were based on Amazon leadership principles. Amazon mainly focuses on those principles.
Tip 1: Revolve your answers around amazon leadership principles.
Tip 2: Make sure you do have good knowledge of your projects.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you create a function in JavaScript?