Question 1:
Implement a method that does basic string compression by counting consecutive repeated characters. If the compressed string is not shorter than the original string, return the original string.
- Discuss time complexity and space complexity
- Discuss edge cases
- Discuss code optimization
Question 2:
Longest Increasing Path in a Matrix.
- You can only move in four directions (up, down, left, right)
- No diagonal moves
- No going out of bounds (no wrap-around)
- The interviewer asked me to use a DFS approach first, then optimize it and run the code
System Design
Design a distributed event processing system that consumes trace events from Kafka and groups all events belonging to the same trace together for processing.
Design premises and assumptions:
- Events are received through Kafka
- Every event contains a traceId
- Events that belong to the same trace share the same traceId
- A trace can last anywhere from a few seconds to a few hours
- The specific processing logic doesn't matter; assume there is already a method that processes all of a trace's events together
Core discussion and follow-up questions:
- How to group events by traceId
- Whether an in-memory approach can scale
- Using an external datastore to hold trace state
- Memory constraints caused by long-running traces
- How to determine that a trace has finished
- How to retrieve the grouped events for downstream processing
- Handling traces that may keep running for hours
- Trade-offs between the different designs
Discussion
Loading comments…