JavaScript Interview with a FAANG engineer.
JavaScript Interview with a FAANG engineer
Interview Summary
Problem type
Tic Tac Toe
Interview question
We are going to implement a "meta" tic tac toe board interface in two parts.
Part 1)
Design a standard tic tac toe board interface.
Given n > 1, implement the following methods:
move(row: int, col: int, player: str or int) -> Nonecheck_game_status(...) -> str:returns whether game is "Ongoing", "Tied", or "Won by player {player}"
Assume that all input "moves" are valid when calling move().
We do not need to store the entire board (which would require O(n^2) extra space).
Part 2)
Given n > 1, design the meta tic tac toe board where:
Each cell of the meta board is a standard tic tac toe board.
The meta board has the following methods:
move(meta_row: int, meta_col: int, row: int, col: int, player: str or int) -> Nonecheck_game_status(...) -> str:returns whether game is "Ongoing", "Tied", or "Won by player {player}"
Interview Feedback
Feedback about Occam's Laser (the interviewee)
Advance this person to the next round?
Yes
How were their technical skills?
4/4
How was their problem solving ability?
4/4
What about their communication ability?
4/4
Thank you for the interview today!
One of the strongest overall performances on the two part question for TicTacToe -> Meta board I've seen on the platform.
Strengths:
- Excellent communicator + appears great to work with
- Clear thought process articulated from overall problem -> examples -> solution strategy
- Easy-to-read code, naming conventions
- Very quick to take simple hints and convert them to practical solutions
- Clear time and space complexity analysis
Potential areas of improvement (mostly nitpicks in this case):- At the end of a solution, proactively volunteer the time and space complexity
-- some interviewers may not explicitly ask for it but still expect it- Object oriented design / inheritance
-- Could have re-used Part 1 solution more directly for Part 2 (instead of copy-paste)- Bullet point some of the main assumptions/hints
-- the hint of not maintaining an entire board for Part 1 could have led to fewer hints to realize the O(n) space solution, but you were quite proactive nonetheless!
- nit: naming conventions consider e.g. rowSums instead of rows
- nit: instead of this.size * this.size consider this.size**2
Further ideas:- Design the meta board to be a 2-player game from the command line
- Build a "computer" player based on a level of difficulty vs player 1
-- Could be random guess (simple) or more sophisticated (like optimizing for a tie)
Feedback about Stochastic Panda (the interviewer)
Would you want to work with this person?
Yes
How excited would you be to work with them?
4/4
How good were the questions?
4/4
How helpful was your interviewer in guiding you to the solution(s)?
4/4
Interview Transcript
Stochastic Panda: Hello.
Occam's Laser: Hi.
Stochastic Panda: How's it going?
Occam's Laser: Fine, fine. How are you?
Stochastic Panda: I'm doing well, thank you for asking. So just want to start off by making sure we're on the same page here. So today we have a senior level target for mock coding round. Is that your understanding as well?
Occam's Laser: Yeah, right.
Stochastic Panda: Fantastic. Fantastic. Okay. Yeah, so we'll conduct this kind of in a standard way. So about five minutes or so for intros, then we'll make for about 40 minutes main coding challenge and then remaining time, basically remaining a recap. Yeah. So for one or two minute introductions.
Occam's Laser: Oops.
Stochastic Panda: Would you like to get us started or shall I? Keeping in mind, of course, this is an anonymous platform, so sharing, comfortable with.
Occam's Laser: Yeah. Okay, I can start. Sure. I'm the web engineer, mostly web engineer for the last eight years. I started even before I went to the university. I had a passion about the web stuff. I started doing freelance stuff with creating websites and so on. And then increasingly, let's say, dig into the back end stuff. And now for the last two, I'm the lead engineer at my company. I lead a few projects in the company. Yeah. And acting as a full stack as developer and tech lead of the few projects. Yeah, maybe briefly. That's it. What about you?
Stochastic Panda: Yeah, that sounds exciting. Thank you. From my side. Well, I've worked at some large tech companies and currently still do from the Pacific Northwest, although recently relocated east coast, and have been focusing a lot for sure on software engineering for the last nine years or so. In my case with a special niche or focus on machine learning ranging from computer vision and more recently some split between time series and so called language processing. At a high level, I might consider myself closer to machine learning engineer scientist, but yeah, that's my brief background there and I've had good experience on this platform for probably over a year now. Yeah, that's brief about me. Any other questions or things you want to cover before we get started?
Occam's Laser: No, we can jump into the coding session.
Stochastic Panda: Excellent. So to begin that part, if you would like to select your preferred coding language for today?
Occam's Laser: Yeah, I would say javascript. I will select in the drop down.
Stochastic Panda: Okay, perfect. Excellent. So I will type in my question and for today it's going to be actually in two parts. So let me start by listing the first part, which we'll talk a little bit about at high level just to make sure we are on the same page. Then I'll paste in part two and we can discuss that a little bit. Then I would propose we jump into the code for part one. Does that kind of make sense?
Occam's Laser: Cool. Yeah.