KatInterview

Real-Time List Filter with Dynamic Maximum Highlighting

Data Structure DesignModel answer
MediumModel answerData Structure Designfrontendstate-managementfiltering

Last updated

Create a filterable transaction list that automatically highlights entries with the highest amount among currently visible results.

Design and implement a transaction list component that displays items with a name and numeric amount. The component must support:

  1. Display all transactions in a list format
  2. Text filtering via a search input that matches transaction names using case-insensitive substring search
  3. Numeric filtering via a minimum amount input that shows only transactions at or above the threshold
  4. Dynamic highlighting that marks all transaction names having the maximum amount among currently visible (filtered) results

Behavior requirements:

  • When multiple transactions share the maximum amount in the filtered view, highlight all of them
  • As filters change, immediately recalculate which transactions have the maximum amount and update highlighting accordingly
  • When no transactions match the filters, display an appropriate empty state with no highlights
  • Handle edge cases: empty datasets, ties, invalid numeric inputs, special characters in names

Design considerations:

Explain your approach to state management (what to store vs. derive), how you efficiently compute the maximum during filtering, and the time/space complexity of your solution. Discuss how you would test the component, including edge cases like extremely large datasets, concurrent filter updates, internationalized text, and boundary conditions in numeric comparisons.

Provide a working implementation demonstrating the core logic.

Hints

Hint 1

Compute derived values (filtered list, maximum, highlights) from source state rather than storing them separately to avoid synchronization bugs

Hint 2

Combine filtering and maximum-finding in a single iteration to avoid redundant passes over the data

Hint 3

Use stable identifiers (indices or IDs) to track which items should be highlighted, not just name matching