From 81336254ae3e1bba98ab545fa220ccf3c0997788 Mon Sep 17 00:00:00 2001 From: chayan das Date: Tue, 18 Nov 2025 23:00:03 +0530 Subject: [PATCH] Create 717. 1-bit and 2-bit Characters --- 717. 1-bit and 2-bit Characters | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 717. 1-bit and 2-bit Characters diff --git a/717. 1-bit and 2-bit Characters b/717. 1-bit and 2-bit Characters new file mode 100644 index 0000000..a68a849 --- /dev/null +++ b/717. 1-bit and 2-bit Characters @@ -0,0 +1,16 @@ +class Solution { +public: + bool isOneBitCharacter(vector& bits) { + int n = bits.size(); + int i = 0; + + while(i < n - 1) { + if(bits[i] == 1) { + i += 2; + } else { + i += 1; + } + } + return i == n - 1; + } +};