FastPrepBilling Log with Undo and Redo
Problems/Billing Log with Undo and Redo

Billing Log with Undo and Redo

Reddit logoReddit● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Reddit phone screen. This version keeps the add, overwrite, undo, and redo operations from the report. The report does not say how a finite batch is written, what the output shows, that history is a single line, or the limits. We supply those details.

A billing amount starts at 0. Process paired arrays operations and amounts in order:

  • ADD adds the paired amount.
  • SET overwrites the current amount with the paired amount.
  • UNDO reverses the most recently applied ADD or SET, if one exists.
  • REDO reapplies the most recently undone change, if one exists.

A new ADD or SET after an undo discards the redo history. Amounts paired with UNDO and REDO are ignored. Return the current amount after every operation.

Function

billingStatusLog(operations: String[], amounts: long[]) → long[]

Examples

Example 1

operations = ["ADD","ADD","UNDO","REDO"]amounts = [5,3,0,0]return = [5,8,5,8]

Undo removes the second addition and redo reapplies it.

Example 2

operations = ["SET","ADD","UNDO","SET","REDO"]amounts = [10,5,0,7,0]return = [10,15,10,7,7]

The new SET after undo clears the redo history, so the final redo is a no-op.

Constraints

  • 1 <= operations.length == amounts.length <= 100000
  • Every operation is ADD, SET, UNDO, or REDO.
  • -1000000000 <= amounts[i] <= 1000000000
  • Every intermediate amount fits in a signed 64-bit integer.

More Reddit interview questions

  • Straight-Line Word SearchPHONE SCREEN · Seen Nov 2026
  • Filter Undesired Comments and Their DescendantsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Tennis Game and Set ScoringPHONE SCREEN · Seen Oct 2026
  • Shortest Word Transformation SequencePHONE SCREEN · Seen Sep 2026
  • Validate a Single-Letter Word SequencePHONE SCREEN · Seen Sep 2026
  • Chatter Message WindowPHONE SCREEN · Seen Jul 2026
  • Reconstruct Billing StatusONSITE INTERVIEW · Seen Jun 2026

Similar questions at other companies

  • Stack with Constant-Time Middle QueriesAmazon · PHONE SCREEN
  • Adding Stack 2.0IMC Trading · OAIMC Trading interview questions
  • Customer Bootstrap APIDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
  • Generic Stack Operation SequenceArista Networks · PHONE SCREEN · ONSITE INTERVIEWArista Networks interview questions
  • Asteroid CollisionSiemens · PHONE SCREEN
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Multiline Text Editor with Cursor MovementDatologyAI · PHONE SCREEN
  • Count Events in Rolling Minute WindowsMeta · PHONE SCREENMeta interview questions
  • Process On-Call Routing OperationsOpenAI · PHONE SCREENOpenAI interview questions

Reddit interview experiences

  • Reddit MLE Notebook Phone Screen: 1 Experience
  • Reddit Experienced SWE and Android Interviews: 3 Experiences
All Reddit interview questionsSee Reddit hiring insights
Saved
class Solution {
    public long[] billingStatusLog(String[] operations, long[] amounts) {
        // Write your code here
    }
}
Checking account…