393. UTF-8 Validation

A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:
For 1-byte character, the first bit is a 0, followed by its unicode code.
For n-bytes character, the first n-bits are all one's, the n+1 bit is 0, followed by n-1 bytes with most significant 2 bits being 10.
This is how the UTF-8 encoding would work:

393. UTF-8 Validation_第1张图片
Given an array of integers representing the data, return whether it is a valid utf-8 encoding.
393. UTF-8 Validation_第2张图片

你可能感兴趣的:(393. UTF-8 Validation)