Back to problems

Validate INDENT/DEDENT Token Sequence

Algorithm · Figma · Easy

Problem You are given a pre-tokenized sequence tokenized that contains three kinds of tokens: INDENT – increases the current indentation level by one. DEDENT – decreases the current indentation level by one. Any other token – these are content tokens and should be ignored for the purpose of this check. Determine whether the indentation structure represented by the sequence is well formed. A sequence is considered well formed exactly when both of these conditions hold: At no…

Checking your access…