mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
36 lines
1.1 KiB
HTML
36 lines
1.1 KiB
HTML
|
<p>We have two special characters:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li>The first character can be represented by one bit <code>0</code>.</li>
|
||
|
<li>The second character can be represented by two bits (<code>10</code> or <code>11</code>).</li>
|
||
|
</ul>
|
||
|
|
||
|
<p>Given a binary array <code>bits</code> that ends with <code>0</code>, return <code>true</code> if the last character must be a one-bit character.</p>
|
||
|
|
||
|
<p> </p>
|
||
|
<p><strong>Example 1:</strong></p>
|
||
|
|
||
|
<pre>
|
||
|
<strong>Input:</strong> bits = [1,0,0]
|
||
|
<strong>Output:</strong> true
|
||
|
<strong>Explanation:</strong> The only way to decode it is two-bit character and one-bit character.
|
||
|
So the last character is one-bit character.
|
||
|
</pre>
|
||
|
|
||
|
<p><strong>Example 2:</strong></p>
|
||
|
|
||
|
<pre>
|
||
|
<strong>Input:</strong> bits = [1,1,1,0]
|
||
|
<strong>Output:</strong> false
|
||
|
<strong>Explanation:</strong> The only way to decode it is two-bit character and two-bit character.
|
||
|
So the last character is not one-bit character.
|
||
|
</pre>
|
||
|
|
||
|
<p> </p>
|
||
|
<p><strong>Constraints:</strong></p>
|
||
|
|
||
|
<ul>
|
||
|
<li><code>1 <= bits.length <= 1000</code></li>
|
||
|
<li><code>bits[i]</code> is either <code>0</code> or <code>1</code>.</li>
|
||
|
</ul>
|