I used my own AI + IDE. The problem was on HackerRank and I shared my screen the whole time.
I got the logger problem.
Part 1
A logger has handlers. Each handler is independent. Handler types:
- Remove all occurrences of a configured string, then print.
- Truncate to N characters, then print.
- Uppercase the whole message, then print.
- Store the message in an internal array without printing.
Discuss the design pattern. Need to make it extensible. Need to support future API use cases.
Part 2
Search the stored messages:
Search for a list of keywords
[x, y, z]
Case sensitive, no punctuation, original log messages are separated by space. Return matching logs if there is a match for ANY keyword, with no duplicates. Optimize time and space complexity.
Part 3. Follow ups
No coding in this part.
What if there are punctuation? And fuzzy matching.
Discuss optimization in production system. (Not related to DB/Caching, just the logger itself.)
What will happen if there is a lot of log messages. How to improve.
Discussion
Loading comments…