Round 1
Questions: Given an input file which is too large to fit entirely in memory and some banned words in another smaller file, we have been given an empty output file. Our task is to replace all banned words with "Banned" and write the entire input file to the output file.
Given:
- Length of each word in banned words file is <= 15
- There is no space in banned words and exact match we need to do only
- We have given already implemented methods like next(), close(), write() for file
Candidate's Approach
I suggested a Trie approach here to add all the banned words to the trie and check line by line in the file to replace banned words with "Banned".
The interviewer agreed and stated that we can assume that methods of the Trie class are also given implemented, such as has(word) -> true, false.
His main aim was to focus on how to read the file in chunks, replace the word as we cannot go back in the file once read, and proper space usage and syntax.
I solved the above question with 2-3 edge cases missing and didn't have time to code that up but explained how to fix them.
Interviewer's Feedback
No feedback provided.