FastPrepApply Binary State Operations
Problems/Apply Binary State Operations

Apply Binary State Operations

ZipRecruiter logoZipRecruiter● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three ZipRecruiter new-grad OA reports from September 2024 describe a load operation that fills the leftmost zero, a clear operation by index, and a final binary string. The reports do not keep a function signature, limits, examples, or reusable image data, so our version supplies a starting state string and clear zero-based command syntax.

For this exercise, assume the initial binary state is supplied as a string state. Apply the strings in operations from left to right:

  • "L": find the smallest index whose current value is 0 and change it to 1. If no zero remains, do nothing.
  • "Cj": change the value at zero-based index j to 0, regardless of its current value. The index may contain more than one digit.

Return the final binary state as a string.

Function

applyBinaryStateOperations(state: String, operations: String[]) → String

Examples

Example 1

state = "00100"operations = ["L","C2","L"]return = "11000"

The first load sets index 0, producing 10100. Clearing index 2 produces 10000. The final load sets the new leftmost zero at index 1.

Example 2

state = "111"operations = ["L","C1","L"]return = "111"

The first load has no zero to change. Clearing index 1 creates the state 101, and the final load sets that position back to 1.

Constraints

  • 1 <= state.length <= 100000
  • state contains only 0 and 1.
  • 1 <= operations.length <= 100000
  • Every operation is either "L" or "Cj" for a valid index 0 <= j < state.length.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024
  • Count Case-Insensitive Key ChangesOA · Seen Sep 2024

Similar questions at other companies

  • Update Pod Counts From LogsSalesforce · OASalesforce interview questions
  • Repeated Maximum and Minimum Request ScoreAmazon · OA
  • Find Total WeightJP Morgan Chase · OAJP Morgan Chase interview questions
  • Insert into a Min-HeapGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Shortest-Job-First Process SchedulingByteDance · PHONE SCREENByteDance interview questions
  • Meeting Rooms III: Most Booked RoomGoogle · ONSITE INTERVIEWGoogle interview questions
  • Dynamic Batch Completion TimesAmbience Healthcare · PHONE SCREEN
  • Automation Pipeline, Part 3: Stage DurationPlaid · PHONE SCREENPlaid interview questions
  • Cursor-Based Pagination Over Sorted LogsRoblox · ONSITE INTERVIEWRoblox interview questions
  • Issue and Reuse 16-Bit TokensMeta · ONSITE INTERVIEWMeta interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public String applyBinaryStateOperations(String state, String[] operations) {
        // Write your code here.
    }

}
Checking account…