Octal Strings

5

2 votes
Easy, Greedy
Problem
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

In 2nd case we do not have 6 and 7 in the string so the answer is -1

In case 3 we require 1 subsequence of "10" and 0 subsequence of "01" which is satisfied in by the string "10".

Editor Image

?