Amazon Interview Experience for SDE-2
Round 1: DS Algo round
The interviewer asked me about briefly my current experience, but that didnt seem like the goal of the interview round.
Then he started with ds algo questions. Below are the specific questions he asked:
- Given a string and “ab”, determine if the string can be generated by “ab”. If it can form, then return true or else return false. Initial assumption is that the given input string will only contain characters ‘a’ and ‘b’.
- Examples:
- “aaabbb” – true
- “caabb” – false
- “abababab” – true
- “aaabbbb” – false
- Basically the rule is, for each ‘a’ in the given string, there should be a corresponding ‘b’ after that ‘a’.
- My solution:
- Have a counter set to 0
- traverse through the string, for each character, if it is ‘a’, increment the counter, if it is ‘b’, decrement the counter.
- At any point in array, if the counter is less than 0, then return false.
- Once the array traversal is over, then if the counter is 0, then return true else return false.
- He then asked to consider the input array having other characters than ‘a’ and ‘b’ as well.
- Asked to write production level code to solve this problem. But I had to only write the method.
- Examples:
- Reverse every k element set of singly linked list.
- Examples:
- list: 1 2 3 4 5 6 7 8 9, k:3 — output: 7 8 9 4 5 6 1 2 3
- list: a b c d e f g h i j k l, k : 4 — output: i j k l e f g h a b c d
- Examples:
Then one more question: What would you do if you have 5 tasks, and a deadline where you can only perform 3 tasks. What would you do?
Round 2: DS Algo (again)
This round also was about ds and algo, but before going to that, he asked a couple of work related questions like:
- Tell me about yourself
- What is the daily work that you have to do, specific to your role and responsibilities
Then he moved to ds algo questions:
- Consider the number keypad of old mobiles. number 2 will be associated with a, b, c. number 3 is associated with d, e, f. number 4 is associated with g, h, i…. so on and number 9 is associated with w, x, y, z. Now, the input to your method is a number. You have to print all the strings that can be formed by that number considering the association described.
- Examples:
- Input is 23 — output would be { ad, ae, af, bd, be, bf, cd, ce, cf}
- Input is 259 — output would be { agw, agx, agy, agz, ahw, ahx, ahy, ahz, aiw, aix, aiy, aiz, bgw, bgx, bgy, bgz, bhw……. ciw, cix, ciy, ciz}
- Examples:
- Zig zag printing of a binary tree of node type as string, but when you are printing right to left, you need to print string in reverse.
- Example:
“abc”
| \
“def” “ghi”
| \ | \
“jk” “lm” “no” “pq”
The output would be:
abc
ihgfed
jklmnopq
Round 3:
I was rejected in the second round. I do not know the reason because I had given right answer to all the questions, and wrote working code on paper as well. Anyways, “kuch koshishen taiyaari ke liye hoti hain” right? 🙂 All the best my fellow geeks!!
Recommended Posts:
- Amazon Interview Experience | Set 431 (For SDE2)
- Amazon Interview Experience for SDE2
- Amazon Interview experience | Set 324 (For SDE2)
- Interview Experience of Amazon - SDE2
- Amazon Interview Experience | Set 381 (For SDE2)
- Amazon Interview Experience SDE2
- Amazon Interview Experience | Set 260 (For SDE2)
- Amazon Interview Experience | Set 430 (For SDE2)
- Amazon Interview Experience | Set 154 (For SDE2)
- Amazon Interview Experience for SDE2 (3 years exp)
- Amazon Interview Experience for SDE2 | 3+ years Experienced
- Walmart Interview Experience for SDE2 | Set 19 (3.8 years experience)
- Flipkart Interview Experience | Set 28 (For SDE2)
- Traveloka Interview Experience for SDE2
- OYO Rooms Interview Experience | Set 5 (For SDE2)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.