FastPrepCustomer Revenue with Direct Referrals
Problems/Customer Revenue with Direct Referrals

Customer Revenue with Direct Referrals

Databricks logoDatabricks● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Databricks phone screen. The original report gives customer IDs that count up on their own, adding a customer with or without a referrer, and queries for the lowest revenue over a threshold. We chose a one-time referral credit paid directly, a threshold that includes its own value, a steady order for ties, and a finite list of operations.

Process a finite ordered sequence of customer-revenue operations. Customer IDs are assigned automatically as 0, 1, 2, ....

  • ["ADD", revenue] creates a customer whose total revenue starts at revenue.
  • ["ADD_WITH_REFERRER", revenue, referrerId] creates a customer and immediately adds that initial revenue once to the existing direct referrer's total. The credit does not propagate to any earlier referrer.
  • ["LOWEST_K", k, threshold] returns up to k customer IDs whose current totals are at least threshold, ordered by total revenue ascending and then customer ID ascending.

Return one integer array per operation: an addition returns a one-element array containing the new ID, and a query returns its ordered customer IDs.

Function

processCustomerRevenueOperations(operations: String[][]) → int[][]

Examples

Example 1

operations = [["ADD","100"],["ADD","40"],["LOWEST_K","2","0"]]return = [[0],[1],[1,0]]

Customer 1 has total 40 and customer 0 has total 100, so the query returns them in that order.

Example 2

operations = [["ADD","50"],["ADD_WITH_REFERRER","20","0"],["ADD_WITH_REFERRER","30","0"],["LOWEST_K","3","25"],["ADD_WITH_REFERRER","40","1"],["LOWEST_K","4","0"]]return = [[0],[1],[2],[2,0],[3],[2,3,1,0]]

The first two referrals raise customer 0 to 100. The last referral raises customer 1 from 20 to 60 but does not propagate to customer 0.

Example 3

operations = [["ADD","10"],["ADD","10"],["ADD_WITH_REFERRER","0","0"],["LOWEST_K","2","10"]]return = [[0],[1],[2],[0,1]]

The threshold is inclusive. Customers 0 and 1 tie at total 10, so customer ID breaks the tie.

Constraints

  • 1 <= operations.length <= 5000.
  • Every operation is well formed and uses one of the three documented names.
  • Every revenue and threshold is a decimal integer in [0, 1000000000].
  • Every referrer ID names a customer created by an earlier operation.
  • 0 <= k <= 5000.
  • Every customer total fits a signed 64-bit integer.

More Databricks Phone Screen questions

  • Rolling Hit CounterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimize CommuteOA · PHONE SCREEN · Seen Oct 2026
  • Top-K Values per Key in MapReducePHONE SCREEN · Seen Oct 2026
  • File Encryption Tree OptimizationPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Encrypted File Count and Minimum TimePHONE SCREEN · Seen Sep 2026
  • Circuit Breaker Database FailoverPHONE SCREEN · Seen Aug 2026
  • Find First Anagram IndexPHONE SCREEN · Seen Aug 2026
  • Ordered IP FirewallPHONE SCREEN · Seen Aug 2026
  • Key-Value Store GET and PUT QPSPHONE SCREEN · Seen Aug 2026
  • Snapshot Set IteratorPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Alert Engine with a Repeat IntervalChronosphere · PHONE SCREEN
  • Query JSON Records with WHERE and ORDER BYGitHub · ONSITE INTERVIEW
  • Camel CardsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Banking System with Top ActivityCapital One · ONSITE INTERVIEWCapital One interview questions
  • Banking System with Pending Transfer AcceptanceCircle · PHONE SCREENCircle interview questions
  • Streaming Top-K Frequent ElementsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Versioned Snapshot SetOpenAI · PHONE SCREENOpenAI interview questions
  • Interview Slot BookingTrueFoundry · PHONE SCREEN
  • Calendar Event System with Pagination and IntersectionLead Bank · ONSITE INTERVIEWLead Bank interview questions

Databricks interview experiences

  • Databricks Senior SWE Onsite AI Rounds: 1 Experience
All Databricks interview questionsSee Databricks hiring insights
Saved
class Solution {
    public int[][] processCustomerRevenueOperations(String[][] operations) {
      // write your code here
    }
}
Checking account…