3
# Submission: https://leetcode.com/submissions/detail/282638543/4
# (Time, Space) Complexity : O(n), O(1)8
def isOneBitCharacter(self, bits: List[int]) -> bool:14
# 1. If bit n is 0, bit n+1 must be a new char15
# 2. If bits end with 1, last bit must be a two bit char16
# However, this case had been rejected by question17
# 3. If 1s in row and end with 0,18
# we can use count or 1s to check last char19
# If count is even, last char is "0"20
# If count is odd, last char is "10"22
# 1. We don't care last element, since it must be 0.23
# 2. We check from reversed, and count 1s in a row24
# 3. Once 0 occur or list end, We stop counting25
# 4. We use count to determin result26
# 5. Since we will mod count by 2, we simplify it to bool28
for bit in bits[-2::-1]: