FunctionRacerProblemsRace

Well-Formed Byte Stream

MediumBitsPython, JavaScript, TypeScript, Java, C++

A text encoding stores every character in 1 to 4 bytes:

data holds bytes as numbers from 0 to 255. Return True if data is a whole number of well-formed characters, one after another, otherwise False.

Example 1

data [226,130,172,65]
returns true

226 is 11100010, so two more bytes must start with 10: 130 and 172 do. 65 starts with 0 and stands alone.

Example 2

data [226,130,65]
returns false

226 asks for two bytes that start with 10, but 65 starts with 0.

Example 3

data [130]
returns false

130 is 10000010, and a byte that starts with 10 cannot begin a character.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Bits problems