Back
Close

King of the hill

Statement
You have to print the number corresponding to the position of the highest hill in the string. A hill is represented by a series of increasing and decreasing numbers. Its height is the value of the number at the top of the hill. The first hill can be only decreasing, then the first number of the sequence is its top. The last hill can be only increasing, then the last number of the sequence is its top. The position of the first hill is one. If there is no hill (as in "000", "1" or "666"), print 0.

Input description
H: the sequence of numbers representing hills

Output description
N: The position of the highest hill in the string.

Constraints
A hill contains only single digit numbers ( 11 corresponds to 1 and 1, not eleven), and they all are positive. If several hills have the same height, keep the rank of the first one.

Game modes

Test cases
1 hill Test
Input
02354310
Output
1

1 hill Validator
Input
1235320
Output
1

2 hills Test
Input
12386456792
Output
2

2 hills Validator
Input
12387356792
Output
2

hills with flat lands Test
Input
122352261232
Output
2

hills with flat lands Validator
Input
123342271232
Output
2

cut at the end Test
Input
1235682312368
Output
1

cut at the end Validator
Input
1235682314568
Output
1

Cut at the beginning Test
Input
21025643894
Output
3

Cut at the beginning Validator
Input
51025643894
Output
3

No hill Test
Input
0
Output
0

No hill Validator
Input
222
Output
0

Solution language

Solution

Stub generator input