Hamburger Sort
Time limit1sMemory limit1024 MB
Given a length-3 string holding (, 1, and ) once each, find the fewest moves that place one character next to another to form (1).
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
A hamburger string is a string where the three characters (, 1, ) appear in that order.
Junhwi made a string by arranging the three characters (, 1, ) in any order. He can repeat this process: pick one character he wants from the string, then place it before or after another character. Find the minimum number of times he must repeat this process to turn into a hamburger string.
Input
A string is given. The length of is , and it contains each of (, 1, ) exactly once.
Output
Print the minimum number of times the process must be repeated to turn into a hamburger string.