FastPrepButton Combination Detector
Problems/Button Combination Detector

Button Combination Detector

SpaceX logoSpaceX● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a SpaceX phone screen. The report asks for a function that detects a specific button combination. It does not say how events are written, how buttons pressed at once work, the edge cases or the limits. Our version is about 72% the same as the reported idea.

Button Combination Detector

A device produces a finite sequence of button events. Every event has the form down:BUTTON or up:BUTTON, where BUTTON is a case-sensitive label.

No buttons are pressed initially. Process the events in order and return true if, after any event, every label in requiredButtons is pressed at the same time. Other buttons may also be pressed. Return false if the required combination never occurs.

Pressing an already pressed button or releasing a button that is not pressed is a valid no-op.

Function

wasButtonCombinationPressed(events: String[], requiredButtons: String[]) → boolean

Examples

Example 1

events = ["down:A","down:B","up:A"]requiredButtons = ["A","B"]return = true

After processing down:B, both A and B are pressed, so the required combination occurs.

Example 2

events = ["down:A","up:A","down:B","down:A"]requiredButtons = ["A","B"]return = true

The first press of A is released before B is pressed. The final event presses A again while B is still down.

Example 3

events = ["down:A","down:C","up:C"]requiredButtons = ["A","B"]return = false

Button B is never pressed, so the required combination never occurs.

Constraints

  • 1 ≤ events.length ≤ 100,000
  • 1 ≤ requiredButtons.length ≤ 100
  • Every required label is unique and matches [A-Za-z0-9_-]{1,20}.
  • Every event is exactly down:BUTTON or up:BUTTON for a valid label.

More SpaceX interview questions

  • Starlink Beam PlannerOA · PHONE SCREEN · Seen Nov 2026
  • Timestamped Telemetry Stream DifferencesPHONE SCREEN · Seen Sep 2026
  • Number of IslandsPHONE SCREEN · Seen Aug 2026
  • Number of Islands IIPHONE SCREEN · Seen Aug 2026
  • Pressure Chamber Linear InterpolationPHONE SCREEN · Seen Jun 2025
  • Speed to Pressure LookupPHONE SCREEN · Seen Mar 2025
  • Simplified Time-Based Key-Value StorePHONE SCREEN · Seen Nov 2023
  • Rocket Component CostONSITE INTERVIEW · Seen Aug 2025
  • DNA Sequence MatchOA · Seen Apr 2025
  • Find the Duplicate NumberONSITE INTERVIEW · Seen Jan 2021

Similar questions at other companies

  • Business Account KYC Verification — Parts 1–5Stripe · PHONE SCREENStripe interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Route Pattern MatcherGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • String Interpolation with a Missing-Value ModeMongoDB · PHONE SCREENMongoDB interview questions
  • Dasher Pay with Store Waits and Peak HoursDoorDash · PHONE SCREENDoorDash interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
  • Fixed-Order Task Run Time With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Character Counts with Retried Remote WorkersCoalition · PHONE SCREEN
  • Risk-Priority Detection StoreCrowdstrike · PHONE SCREENCrowdstrike interview questions

Interview reports that mention this question

  • 2013–2026 SpaceX Full-Time OA / Interviews: 45 Experiences (Part 2 :)
  • SpaceX Software Engineer OA and Interviews: 27 Experiences
  • SpaceX Software Engineer Button Combination Task: 1 Experience

SpaceX interview experiences

  • SpaceX Full-Time Interview Cycle and Delayed Decision
  • SpaceX Experienced Engineer Full-Time Thirteen-Interview Process
  • SpaceX Senior Hardware Engineer Full-Time Interrupted Onsite
All SpaceX interview questionsSee SpaceX hiring insights
Saved
class Solution {
    public boolean wasButtonCombinationPressed(String[] events, String[] requiredButtons) {
        // Write your code here.
    }

}
Checking account…