717. 1-bit and 2-bit Characters Easy
1/**
2 * [717] 1-bit and 2-bit Characters
3 *
4 * We have two special characters:
5 *
6 * The first character can be represented by one bit 0.
7 * The second character can be represented by two bits (10 or 11).
8 *
9 * Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.
10 *
11 * Example 1:
12 *
13 * Input: bits = [1,0,0]
14 * Output: true
15 * Explanation: The only way to decode it is two-bit character and one-bit character.
16 * So the last character is one-bit character.
17 *
18 * Example 2:
19 *
20 * Input: bits = [1,1,1,0]
21 * Output: false
22 * Explanation: The only way to decode it is two-bit character and two-bit character.
23 * So the last character is not one-bit character.
24 *
25 *
26 * Constraints:
27 *
28 * 1 <= bits.length <= 1000
29 * bits[i] is either 0 or 1.
30 *
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/1-bit-and-2-bit-characters/
35// discuss: https://leetcode.com/problems/1-bit-and-2-bit-characters/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40 pub fn is_one_bit_character(bits: Vec<i32>) -> bool {
41 false
42 }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn test_717() {
53 }
54}
55
Back
© 2025 bowen.ge All Rights Reserved.