Amazon SDE II Intern | Coding challenge | Interview experience | August 2024 | [Offer]
Online Assessment
Questions:
-
Select prefix of any length from an array and decrement each element in that prefix length by 1. Make sure no element becomes negative. Count maximum number of zeros after all possible operations.
- Sample case: [3,2,4,4,1]
- Output: 3
- Explanation: Select prefix of size 5, [3,2,4,4,1] -> [2,1,3,3,0]. Now choose prefix of size 4, [2,1,3,3,0] -> [1,0,2,2,0]. Now we have to choose prefix of size 1 because 1st index will become negative if we try to make further elements smaller... [1,0,2,2,0] -> [0,0,2,2,0].
- Time complexity: O(n)
-
Given an array of strings and a threshold value, count the number of segments which have count of vowels less than or equal to the value of the threshold.
- Sample case: ["lciy","ttrd","aod"], threshold = 1
- Output: 3
- Explanation: Segments with vowel count less than or equal to 1: ["lciy"],["lciy","ttrd"],["ttrd"].
- Relatable question: Find the Number of subarrays having sum less than K using C++ (tutorialspoint website).
- Time complexity: O(n^2) (brute force method).
Candidate's Approach
I solved both questions and got shortlisted for the interview. For the first question, I figured out the optimal solution during the exam. For the second question, I worked with a brute force method.
Interviewer's Feedback
No feedback provided.
Interview Experience
Questions:
-
Easy string (GFG question) with modifications:
- Modifications: i) String consisted only of lowercase letters. ii) If a character occurred more than 9 times, return "9" + "that char" and continue counting again.
- Sample case 1: "aaaaaaaaaaaaaabbeee"
- Output: "9a5a2b3e"
- Sample case 2: "abcde"
- Output: "1a1b1c1d1e"
- Time complexity: O(n)
-
Check if leaf traversal of two Binary Trees is the same? (GFG question)
- I initially gave a wrong approach of level order traversal, but after the interviewer provided another sample case, I figured out the correct approach and coded it.
Interviewer was quite impressed with my solutions and said he didn't have any more questions. He asked if I had any questions for him. I asked: "What is the definition of a good code according to you sir? When a student writes a code, what are the key elements that you look into?"
The interviewer answered my question and then informed me that the recruiting team would update me with the further steps before ending the meeting.
I GOT HIRED!!
Candidate's Approach
I got the first string question right in a single go, as it was pretty simple and straightforward. For the second question, I initially made a mistake but corrected it after the interviewer guided me with a sample case.
Interviewer's Feedback
The interviewer was impressed with my solutions and mentioned that he didn't have any more questions for me.