Round 1
Questions: Your organization has started a new tech blog with interesting tech stories and you’re responsible for designing and implementing an in-memory search engine, supporting the search functionality on the blog content.
Requirements:
- It should be possible to create a dataset in the search engine.
- It should be possible to insert and delete documents in a given dataset. Each document is simply a piece of text.
- It should be possible to search through documents for a search pattern in a given dataset.
- It should be possible to order the search results.
// Java code provided in the post
Test Cases:
------ TEST CASE - 1 ------ searchService.searchBlog("AI") ------ TEST CASE - 2 ------ searchService.searchBlog("AI EVERYWHERE ") ------ TEST CASE - 3 ------ searchService.searchBlog("AI EVERYWHERE ") ------ TEST CASE - 4 ------ searchService.searchBlog("AI IS ") ------ TEST CASE - 5 ------ searchService.searchBlog("MGRS") ------ TEST CASE - 6 ------ searchService.searchBlog("MGRS") ------ TEST CASE - 7 ------ searchService.searchBlog("AI")
Candidate's Approach
The candidate designed an in-memory search engine using Java, implementing functionalities to create datasets, insert and delete documents, and search through the documents. The approach included using a singleton pattern for the blog repository, an observer pattern for notifying changes in the blog service, and a strategy pattern for sorting search results. The candidate also provided test cases to validate the implementation.
Interviewer's Feedback
No feedback provided.