Preparing for an interview? Check out Cracking the Coding Interview
Published on

Amazon SDE II Intern | Coding challenge | Interview experience | August 2024 | [Offer]

Author
  • Shared Anonymously

I wanted to share my recent internship journey,. Here’s how it went:-
I didn't get shortlisted in any exam though i gave around 12-15 exams... amazon was the first company that shortlisted me in the online assessment and I cleared the interview in a single go.

ONLINE ASSESSMENT (2 questions, 70 minutes):-

1. 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
Explaination:- 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].

Had to do this in time complexity of O(n). Thinking of the optimal solution is bit difficult but luckily I figured it out in the exam.

2. 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
Explaination:- 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)

Worked with brute force method with time complexity of O(n^2).

I solved both the questions and got shortlisted for the interview.

INTERVIEW EXPERIENCE:-
Basic introduction then started with DSA questions....

  1. Easy string (gfg question)
    A bit modification in this question...
    Modifications :-
    i) String consisted only lowercase letters.
    ii) If a character occured more than 9 times then we have to return "9" + "that char" and continue counting again.
    Sample case 1:- "aaaaaaaaaaaaaabbeee"
    Output:-"9a5a2b3e"

Sample case 2 :- "abcde"
Output :- "1a1b1c1d1e"

Got it right in a single go... was pretty simple and straight forward. (O(n) approach).

  1. Check if leaf traversal of two Binary Trees is same? (gfg question)
    Exact Same question was asked.

First I gave a wrong approach of level order traversal then interviewer made me realise its wrong by giving another sample case then i figured out the correct approach and coded it.

Interviewer was quite impressed with my solutions and said he didnt have any more questions.
He asked me if I had any questions for him... Question asked by me:-
"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 answered it and then he told me that the recruiting team will update me with the further steps and ended the meet.

I GOT HIRED!!

ReportMark as Helpful