This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
GoalTed wants to develop a compiler and knows that one of the most important elements in a compiler is its parser
Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar.
Today, Ted is concerned with an abstract instruction which is composed of the characters
He understand that, for an expression to be valid, a
So, for instance, the instructions:
are all valid. While:
Given expression which represent some instructions to be analyzed by Ted's compiler, you should tell the length of the longest prefix of this expression that is valid, or 0 if there is not such a prefix.
Input will consist of a single line, representing a possible expression in T++.
You should output the length of the longest prefix that is valid or
0 if there is not such a prefix
1 ≤ The length of line ≤ 100
A higher resolution is required to access the IDE