# Leetcode 717 - 1-bit and 2-bit chars

Note:

• Use DFS by repetitively slicing off the last element.
• Remove the last 0 from bits first.
• Base case:
• arr is empty, return true;
• Only one 0 left, return true;
• Only one 1 left, return false;
• When last bit is 0:
• When the last but one is 0, only slice off the last 0.
• When the last but one is 1, two situations: Choose to only slice off 0 or 10 together.
• When last bit is 1:
• When the last but one is 1, slice off the last 2;
• When the lst but one is 0, return false;

Question:

We have two special characters:

• The first character can be represented by one bit 0.
• The second character can be represented by two bits (10 or 11).
Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.

Example:

Code: