Binary String Flip and Prefix Zero Counts
Updated
Problem statement
Maintain binaryString under requests:
flipinverts every bit and emits no output.count:indexappends the number of zeros from index 0 through the valid zero-based index, inclusive.
Return count answers in request order.
Function
binaryPrefixZeroCounts(binaryString: String, requests: String[]) → int[]Examples
Example 1
binaryString = "1111010"requests = ["count:4","count:6","flip","count:4","flip","count:2"]return = [1,2,4,0]Prefix counts use the current inversion state without emitting values for flips.
Example 2
binaryString = "0"requests = ["count:0","flip","count:0"]return = [1,0]The one bit changes from zero to one.
Constraints
1 <= binaryString.length,requests.length <= 100000
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
- Apply Binary State OperationsOA · Seen Sep 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
Similar questions at other companies
- Earliest Time to Schedule a MeetingMathWorks · OAMathWorks interview questions
- Earliest Meeting Start on a 24-Hour ClockIMC Trading · OAIMC Trading interview questions
- Earliest Time to Schedule a MeetingMicrosoft · OAMicrosoft interview questions
- Maximum Equalized Substrings After One Adjacent SwapVisa · OAVisa interview questions
- Maximum Redundancy After One Segment FlipBloomberg LP · OABloomberg LP interview questions
- Balanced Split String with WildcardsTwo Sigma · OATwo Sigma interview questions
- Longest Balanced Substring After One SwapTekion · OATekion interview questions
- Shortest Compressed Length After RemovalDRW · OADRW interview questions
- Count Special StringsAmazon · OA
- Maximum Positive FeedbackTikTok · OATikTok interview questions