UTF-8 is a variable-length character encoding. A 1-byte character starts with 0, a 2-byte with 110, a 3-byte with 1110, a 4-byte with 11110. Continuation bytes start with 10. Given an array of integers representing byte values, determine if it is a valid UTF-8 encoding. Input: first line n, second line n integers. Output "true" or "false".
Example 1:
Example 2:
Constraints:
1 <= n <= 10^4 0 <= byte <= 255
Tags:
