Maximum Binary Circuit Segregation Cost
Updated
Problem statement
Move all zeroes before all ones in the binary string s. In one operation, choose a 1 with a zero immediately to its right and move that one as far right as possible, stopping just before the next one or at the end of the string.
The operation costs 1 + distance moved. Return the maximum total cost over all sequences that finish with every zero before every one. An already grouped string has cost zero.
Function
getMaxCost(s: String) → longExamples
Example 1
s = "110100"return = 13Two one-position moves cost 2+2. Then each of the three ones moves two positions at cost 3. The total is 2+2+3+3+3=13.
Example 2
s = "1010"return = 6Use 1010 → 0110 → 0101 → 0011. Each move costs 2, giving 6.
Constraints
- For this exercise, assume 1 <= s.length <= 100000.
- s contains only 0 and 1.
Source note: Original OA task images and any included source example. The practice contract follows the rules stated in the problem and source note.
More Adobe Online Assessment questions
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Count Parent Nodes With a Target SumOA · Seen Aug 2026
- Largest Binary Number by ConcatenationOA · Seen Aug 2026
- Count Events by CategoryOA · Seen Aug 2026
- Graph M-ColoringOA · Seen Aug 2026
- Hall of Shifting TilesOA · Seen Aug 2026
- K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
- Maze ReachabilityOA · Seen Aug 2026
- Minimum Numeric Code TransformationOA · Seen Aug 2026
Similar questions at other companies
- Return Exact Cash Register ChangeBank of America · OA
- Minimum Digit Swaps for the Smallest DifferenceLSEG · OALSEG interview questions
- Binary CircuitAkuna Capital · OAAkuna Capital interview questions
- Minimize Expression with ParenthesesPinterest · OAPinterest interview questions
- Digit Changes for a Multiple of 9Nutanix · OANutanix interview questions
- Minimize Difference Between Two NumbersMicrosoft · OAMicrosoft interview questions
- Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
- Smallest Number With a Given Digit SumAmazon · ONSITE INTERVIEW
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions
Adobe interview experiences
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
- Adobe Product Intern Interviews: 15 Experiences (Part 3 of 4)