Confusable number (Javascript)
JavaScript Interview with a FAANG engineer
Interview Summary
Problem type
Confusable number
Interview question
Consider an auction: there are BIDDERS in the audience. Each BIDDER is given a paddle with a unique number (e.g.: 57). At the front, there is an ORGANIZER. When a BIDDER raises their paddle, the ORGANIZER sees it and recognizes the number. For instance, a BIDDER might raise paddle #78, and the ORGANIZER recognizes the number 78.
Sometimes, however, a BIDDER accidentally holds the paddle upside down. For instance, a BIDDER with the number 68 holds it upside down, showing the number 89. The ORGANIZER assumes it's 89, which is a mistake. We'll call any number that--when turned upside down--is a different, valid number, a CONFUSABLE number.
Write a function that, given a room with 800 BIDDERS, identifies all the confusable numbers.
Read more about the questions
Interview Feedback
Feedback about Fresh Bear (the interviewee)
Advance this person to the next round? No
How were their technical skills? 3/4
How was their problem solving ability? 3/4
What about their communication ability? 3/4
Pros:
- Good job making an assumption that the bidders go from 1 to 800
- Good job talking through the problem statement
- Good job deciding that 1 is reversible
- Good job focusing on digits up front
- Good job thinking out loud
- Good job clarifying about input/output parameters
- Good job identifying leading zero edge case
- Good job thinking through more use cases after we clarified about the definition of confusable number
- Good job using examples to help understand the problem space
- Good job asking about whether we should pursue a more performant solution
Things to think about:
- Missed digit '0', but you did remember to add it later
- If your question is "this seems simple; am I missing something?", the answer is probably "yes"
- Write down your assumptions (e.g.: number-with-2345-inverted-is-by-definition-not-confusable)
- When listing confusables between 1 - 20, you missed 18. I wonder if there's an opportunity to improve thoroughness?
Things to improve:
- Missed the part of the confusable number definition (must be different number)
- Initial implementation of isCharsConfusable is incorrect (includes 9).
- Missed the upside-down-is-same case
Verdict: Strong no hire. Didn't think through test cases thoroughly, and the solution is incomplete.
Recommendations:
- Understand the stages: requirements refinement, algorithm definition, algorithm implementation
- Improve requirements refinement: identify MORE test cases
Feedback about Sly Chinchilla (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
Sly Chinchilla: Hello, hello, hello.
Fresh Bear: Hey, how are you doing?
Sly Chinchilla: I'm great. Can you hear me okay?
Fresh Bear: Yeah, can you hear me okay?
Sly Chinchilla: Absolutely. This is, um, this is a rare event that both of us have a working AV setup right out of the gate. Wow, that's awesome.
Fresh Bear: Yeah, they don't have a setup mode. So that's probably why people mess up.
Followed by the discussion of the interview structure and problem exploration.
Examined Test Cases and Edge Cases
- Clarification on the ability to identify confusable numbers.
- Step through various numbers, analyzing their potential confusability.
- Communication among analogs such as 1, 6, 8, 9 and identification of implications of either lowercase or flipped representations.
Conclusion and Key Observations
- Detailed discussion indicating the need for structured exploration of algorithms.
- Importance of acknowledging distinctive aspects of test cases and assumptions while iterating through solutions.