Status: 1 year of experience
Position: ICT-3 at Apple
Location: London, UK
Date: June 2022
I was not able to find a lot of interview experience for Apple on leetcode. So I though I'll give a detailed account of mine.
Applied on apple jobs portal and recruiter reached out to schedule 2 rounds of initial interview. All rounds are over Webex and coding is on Coderpad.
30 minutes - Behavioural interview with Hiring manager
45 minutes - DSA round- Similar to https://leetcode.com/problems/valid-sudoku/ , but was given a fully filled board. Follow ups on how to extend solution to an nxn board, how would you test your solution, how would you generate new test cases. I think I finished this round earlier than interviewer expected.
Was invited for 4 rounds of onsite interview after this.
Round 1 - System design
type Elevator {
currentFloor
currentDirection
gotoFloor(floor){}
}This was the base given and had to continue the design from there.
I ended up suggesting two functions to handle input from user.
floor and direction as input and another from inner panel of an elevator which gets elevator, floor as input.Round 2 - Coding
class Problem:
def increment():
def get_value() -> Returns number of times increment was called in last 5 mins , accuracy only upto seconds was requiredInitial approach - I kept timestamps everytime increment is called in a queue and returned scanned the entire queue till timestamp > 300 seconds ago when get_value is called
Optimization : Only have one entry in queue per second and it would contain number of calls in that particular second. So entry would look like (timestamp, count_in_this_second_interval). get_value would only have to scan a maximumum of previous 300 entries in this case to get the count.
Follow up: Is this code thread safe, which parts are critical section, how would you synchronize this.
Leetcode Equivalent (Premium) : https://leetcode.com/problems/design-hit-counter/ - Thanks to @kmess024 for pointing this out
Round 3 - Behavioral Round
Round 4 - Coding
"""
-----------|-------------------------|-------------------
c1 | c2 | c3
-----------|----|--------------------|----------------|-----
l1 (4 bytes) | msg1 (l1 bytes) | l2 (4 bytes)
----------------|-------------------------------------|------
"""
class StreamReceiver:
def receive (chunk):
def accept(msg):We recieve a stream of messages in chunks(c1,c2...) of different size. Each message has a format of first 4 bytes denotes length(number of bytes) of message and next length bytes is the message.
The recieve method is called when a chunk is recieved. We have to parse out messages and call accept with the fully parsed messaged. So in the example above we would call accept for the first time after parsing a portion of c3 chunk.
Each chunk could be of any number of bytes as is evident from the diagram above.
I talked about an approach but fumbled in describing it to interviewer. He told me he understood what I was trying to say but told me to think of another approach, so I wasnt very clear on what he wanted and finally we circled around to the same approach I had initially tried to talk about and he said that was the right approach and asked me to code it out. Pretty sure this round is a goner. Coded it out and he was satisfied with it as well. As usual got asked about some concurrency and critical section around this as well.
I was told they would regroup and discuss and get back in a couple of days. Didnt receive any communication after that and the position was marked as closed in the portal. I was aware that they were interviewing aggresively so its safe to assume the role was closed with someone else. Also I am pretty sure I messed up all the concurrency follow up questions, so was not very confident about getting through.
My takeaway : Apple doesnt really focus on DSA as much as all the other big tech I guess. The questions were designed such that people can interview even without a significant preparation on leetcode style DSA. The system design round was more low level design than high level design. Most important of all, they are heavily heavily concerned about concurrency. Concurrency was asked in almost all the rounds, so you might as well look that up and sychronization stuff for Apple interview. Another thing is the team has complete autonomy over the questions and interview. So I guess there is no common pattern or style of interview. The only common element might be the focus on Concurrency. Also all onsite interviews had 2 folks: a main interviewer and a shadow, except for the behaviuoral round where they took turns asking the questions.
Hope this helps someone!! Will post about my upcoming google, amazon onsite fails in the next post. :)