Panda Guru LogoPanda
Guru

Google | Phone Screen | SWE3

Round 1

Questions: The interviewer presented a problem titled "Two Player Game": There are two people who will each have an equal number of tiles. We need to write a function that evaluates who will win.

  1. Can you write a signature for the function?
  2. Let's say the tiles have numbers on them, so they are lists of numbers. The player who has the max wins. What happens if the two players have the same max?
  3. How large are the lists? Are they sorted?
  4. Instead of heaps, could you have used any other approach?
  5. What if the PM gets back to you with a request for change? Now tiles contain numbers 2-9 and letters A for 1 and B for 10. How do you modify the code for that?
  6. Now there is another change request. There is also 'C' for value 11.
  7. Now to win, you must check the frequency of numbers, and then compare the value. What happens if the highest frequency number is the same in both lists?
def playGames(tiles1, tiles2): return #1 or 2 or True/False based on who wins
Candidate's Approach
  • The candidate started by defining the function signature and discussed the rules of the game.
  • They proposed using heaps to determine the maximum values from the lists of tiles.
  • The candidate acknowledged the potential for a draw and suggested returning different values for win conditions.
  • They later modified their approach to handle letters A, B, and C by preprocessing the tiles.
  • The candidate also discussed using a dictionary for conversion and mentioned the use of a custom counter for frequency checks.
Interviewer's Feedback
  • The interviewer appreciated the candidate's clarifying questions and their thought process regarding edge cases.
  • They noted that they did not prioritize Big O complexity for this question but advised the candidate to clarify such expectations in future interviews.
  • The interviewer recommended a book by Alex Xu for preparing for system design interviews.