文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

1. Description

Leetcode 717. 1-bit and 2-bit Characters

2. Solution

class Solution {
public:
    bool isOneBitCharacter(vector<int>& bits) {
        int step = 1;
        int index = 0;
        while(index < bits.size()) {
            step = bits[index]==1?2:1;
            index += step;
        }
        return step == 1;
    }
};

Reference

  1. https://leetcode.com/problems/1-bit-and-2-bit-characters/description/

相关文章:

  • 2021-10-07
  • 2022-02-10
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2021-04-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2022-01-12
  • 2019-01-18
  • 2022-02-25
  • 2021-07-26
相关资源
相似解决方案