Amazon SDE II | Coding Challenge | Interview Experience | August 2024 | [Offer]
Summary
I recently completed my Amazon SDE II coding challenge and interview, successfully receiving an offer after clearing both rounds. My journey involved an online assessment with two challenging coding problems and an interview focusing on DSA, ultimately leading to a job offer.
Full Experience
My internship journey started with a pleasant surprise when Amazon shortlisted me for their online assessment, despite my previous attempts with other companies. It was my first success in the online assessment stage, and I was determined to make it count.
Online Assessment:
The online assessment consisted of two coding questions to be completed in 70 minutes.
The first question involved decrementing elements in a prefix of an array to maximize the number of zeros without any element becoming negative. I needed to find an O(n) solution, which was quite challenging to conceptualize, but I managed to figure out the optimal approach during the exam.
The second question asked me to count segments within an array of strings where the total vowel count was less than or equal to a given threshold. For this one, I implemented a brute-force O(n^2) method, which also worked.
Solving both questions successfully led me to be shortlisted for the interview round.
Interview Experience:
The interview began with a basic introduction, after which we dived straight into Data Structures and Algorithms.
The interviewer presented a string compression problem with specific modifications. The string would only contain lowercase letters, and if a character occurred more than nine times consecutively, I had to represent it as '9' followed by the character, then continue counting the remaining occurrences (e.g., 15 'a's would be '9a5a'). I understood the problem quickly and implemented an O(n) solution right away, which was quite straightforward.
The interviewer then presented another problem. Initially, I proposed an incorrect approach involving a level-order traversal. The interviewer patiently guided me by providing a different sample case, which helped me realize my mistake. I then corrected my approach, figured out the right solution, and coded it successfully.
The interviewer seemed quite impressed with my solutions and indicated he had no further technical questions. He then offered me a chance to ask him questions. 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?' He provided a detailed answer, after which he informed me that the recruiting team would contact me regarding the next steps, and our meeting concluded.
Shortly after, I received the news: I GOT HIRED!
Interview Questions (3)
Given an array, select a prefix of any length and decrement each element in that prefix by 1. Ensure no element becomes negative. Count the 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]. The solution should be 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 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 cplusplus
Implement a run-length encoding scheme with specific modifications:
1. The input string consists only of lowercase letters.
2. If a character occurs more than 9 times consecutively, encode it as '9' + 'that char' and then continue counting the remaining occurrences. For example, for 15 'a's, it would be '9a5a'.
Sample case 1: "aaaaaaaaaaaaaabbeee"
Output: "9a5a2b3e"
Sample case 2: "abcde"
Output: "1a1b1c1d1e"
The solution should be O(n).