Ai
1 Star 2 Fork 5

LilithSangreal/LeetCode-Solutions

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
1-bit-and-2-bit-characters.cpp 302 Bytes
Copy Edit Raw Blame History
kamyu authored 2017-10-29 17:13 +08:00 . Create 1-bit-and-2-bit-characters.cpp
// Time: O(n)
// Space: O(1)
class Solution {
public:
bool isOneBitCharacter(vector<int>& bits) {
auto parity = 0;
for (int i = static_cast<int>(bits.size()) - 2;
i >= 0 && bits[i]; --i) {
parity ^= bits[i];
}
return parity == 0;
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LilithSangreal/LeetCode-Solutions.git
git@gitee.com:LilithSangreal/LeetCode-Solutions.git
LilithSangreal
LeetCode-Solutions
LeetCode-Solutions
master

Search