FastPrepPlatform Referral Rewards
Problems/Platform Referral Rewards

Platform Referral Rewards

Scale AI logoScale AI● MediumNEW GRADINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Scale AI online assessment. We rebuilt the question. It keeps a referral forest with no cycles, records in any order, bonuses that can be positive or negative, and a ranking by reward from high to low, with ties in alphabetical order. An ancestor d links above a worker gets that worker's base bonus plus d - 1. The sample in the report ranks A,C,B,E,D. We chose to give the records as strings, and to allow names of ASCII letters and digits up to 40 characters. The report only rules out whitespace in names. Our version is about 95% the same as the reported question.

Each string in records has the form worker referrer bonus. referrer is another worker name or None. Records may arrive in any order.

For every worker with a referrer and bonus b, the direct referrer earns b, that referrer's referrer earns b+1, the next ancestor earns b+2, and so on to the root. Bonuses may be positive, zero, or negative. Workers do not earn their own listed bonus.

Return all worker names sorted by decreasing total reward. Break equal-reward ties lexicographically.

Function

platformReferralRanking(records: String[]) → String[]

Examples

Example 1

records = ["A None 0","B C 5","C None 0","D A 10","E D -3"]return = ["A","C","B","E","D"]

Rewards are A=8, C=5, B=0, E=0, and D=-3.

Example 2

records = ["B A 2","C B 2","A None 0"]return = ["A","B","C"]

A earns 2 from B and 3 from C, while B earns 2 from C.

Example 3

records = ["Z None 0","A None 0"]return = ["A","Z"]

Both rewards are zero, so lexicographic order decides the result.

Constraints

  • 1 <= records.length <= 200000.
  • Every record contains a unique worker name, a referrer name or None, and a signed 32-bit bonus.
  • Worker names are nonempty ASCII alphanumeric strings of length at most 40.
  • The referral relation is acyclic and every named referrer belongs to the same forest.
  • Every total reward fits in a signed 64-bit integer.

More Scale AI Online Assessment questions

  • Part 2: Batch Access ReviewOA · Seen Nov 2026
  • Part 1: The Narrowest KeyOA · Seen Nov 2026
  • Build Sessions from Unordered Events (Part 1)OA · Seen Oct 2026
  • Match Billing Charges to User Sessions (Part 2)OA · Seen Oct 2026
  • Four-Player Trick-Taking Card Game SimulationOA · PHONE SCREEN · Seen Aug 2026
  • Free Windows Between Busy IntervalsOA · PHONE SCREEN · Seen Apr 2026
  • Compare Labeling Worker AnnotationsOA · Seen Mar 2025
  • Count Stable Server SubsegmentsOA · Seen Nov 2024
  • Distinct OR Values of Increasing SubsequencesOA · Seen Nov 2024
  • Running Through Walls with Limited EnergyOA · Seen Sep 2024

Similar questions at other companies

  • Maximum Reservoir PowerWells Fargo · OAWells Fargo interview questions
  • Shipping Starts and Terminal DestinationsIntuit · OAIntuit interview questions
  • Minimum Leaf Path Sum over All RootsInfosys · OAInfosys interview questions
  • Divide Tree NodesGoogle · OA · ONSITE INTERVIEWGoogle interview questions
  • Minimum Satellite Data Transfer IterationsHSBC · OAHSBC interview questions
  • Maximum Strength of Every NeuronMicrosoft · OAMicrosoft interview questions
  • Tree Node With Maximum BeautyC3.ai · OAC3.ai interview questions
  • Top-Down Employee Reporting ForestOkta · ONSITE INTERVIEWOkta interview questions
  • Aggregate Machine TopologyOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Distance Sums to Special Nodes in a Weighted TreeNutanix · ONSITE INTERVIEWNutanix interview questions

Interview reports that mention this question

  • Scale AI OA: What It Tests (2026)
  • Scale AI New Grad SWE and MLE Question Bank
  • Scale AI New Grad SWE OA Question: 1 Experience

Scale AI interview experiences

  • Scale AI Forward Deployed Engineer Debugging Round: 1 Experience
  • Scale AI ML Research Engineering Intern Interviews: 1 Experience
  • Scale AI SWE Intern Debugging Interview: 9 Experiences
All Scale AI interview questionsSee Scale AI hiring insights
Saved
class Solution {
    public String[] platformReferralRanking(String[] records) {
        // write your code here
    }
}
Checking account…