Move Bits to Right
Problem Overview
- Move all 1s to the right in a binary string and compute the maximum total operation cost.
- Input: binary string; Output: maximum cost; each operation moves a '1' k steps right for cost 1+k, and must push that '1' as far right as possible.
- Context: integrated binary circuit signal shifting.
- From Google interviews; a coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
