Filter Isolated Interior Signal Bits
Updated
Problem statement
Given a binary signal string, replace every interior 1 whose immediate left and right neighbors are both 0 with 0. Determine all replacements from the original signal, so removals are simultaneous. Keep the first and last bits unchanged.
Function
filterIsolatedInteriorBits(signal: String) → StringExamples
Example 1
signal = "01010"return = "00000"Both interior one bits are isolated in the original signal and are removed simultaneously.
Example 2
signal = "11011"return = "11011"No one bit has zero-valued neighbors on both sides.
Constraints
1 <= signal.length <= 200000signal[i] is '0' or '1'
More SEDEMAC interview questions
Similar questions at other companies
- Branch with the Most FilesCapital One · OACapital One interview questions
- Robot Stops Left or Right (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
- Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
- REST API: Highest International StudentsRippling · OARippling interview questions
- Rearrange String by Alternating EndsHudson River Trading · OAHudson River Trading interview questions
- Scale Ingredient QuantitiesUpstart · OAUpstart interview questions
- Telephone Keypad String EncodingEpic · OAEpic interview questions
- Count Invalid Log GroupsIBM · OAIBM interview questions
- Count Case-Insensitive TripletsTikTok · OATikTok interview questions
- Simulate a Deterministic Finite AutomatonPoint72 · OAPoint72 interview questions