Round 1 (DSA)
Questions:
-
Given a text/String, return exactly K most frequent words.
- Sample Input:
text = "I am who I am" K = 1
- Follow Up: How would you handle the case where there are more than K words having maximum frequency? It was suggested that in case of a tie, use a lexicographical order, which could be accommodated in the Priority Queue Comparator Logic.
- Sample Input:
-
Stack Parentheses Question
- Check if a given String is a valid Parentheses.
- Case 1: Valid Parentheses
- Extend the solution for Case 1 to return the length of the longest valid parentheses for the same string.
- Case 2: Longest Valid Parentheses
Candidate's Approach
Solved the first question using a Map and Priority Queue. For the follow-up, discussed using a comparator for lexicographical order in case of ties.
For the second question, implemented the logic to check for valid parentheses and extended it to calculate the maximum length of valid parentheses.
Interviewer's Feedback
No feedback provided.
Round 2 (Low Level Design)
Questions:
- Design a Board Game with the following specifications:
- An n*n board with areas marked with obstacles where a player cannot go.
- Two players starting at opposite corners of the board.
- Objective: Players move and collect coins, with new coins regenerating based on given logic.
Candidate's Approach
Provided a basic class design including:
- Game
- Player
- GameLoader
- BoardGeneratorService
- GameInteractionService
Discussed high-level interfaces for the same. Initially placed the GameInteractionService in the wrong class but corrected it during the interview.
Interviewer's Feedback
Was grilled on the need for a GameInteractionService and its correct placement. The candidate took some time to correct the rationale, which may have contributed to the rejection.