Back to problems

Customer Revenue System

Object-Oriented Programming · Databricks · Medium

Balanced BST with Per-Customer Records The system must track each customer's total revenue — the sum of their own direct contributions and any revenue from directly referred customers — and quickly answer "who are the top K earners above a given threshold". A straightforward list would require O(N) updates and O(N log N) queries, but we can do better. The central idea is to keep every customer record in a balanced binary search tree (such as Java’s TreeSet or Python’s…

Checking your access…