classSolution: defisOneBitCharacter(self, bits: List[int]) -> bool: i, n = 0, len(bits) while i < n - 1: i += bits[i] + 1 return i == n - 1
[sol1-C++]
1 2 3 4 5 6 7 8 9 10
classSolution { public: boolisOneBitCharacter(vector<int> &bits){ int n = bits.size(), i = 0; while (i < n - 1) { i += bits[i] + 1; } return i == n - 1; } };
[sol1-Java]
1 2 3 4 5 6 7 8 9
classSolution { publicbooleanisOneBitCharacter(int[] bits) { intn= bits.length, i = 0; while (i < n - 1) { i += bits[i] + 1; } return i == n - 1; } }
[sol1-C#]
1 2 3 4 5 6 7 8 9
publicclassSolution { publicboolIsOneBitCharacter(int[] bits) { int n = bits.Length, i = 0; while (i < n - 1) { i += bits[i] + 1; } return i == n - 1; } }
[sol1-Golang]
1 2 3 4 5 6 7
funcisOneBitCharacter(bits []int)bool { i, n := 0, len(bits) for i < n-1 { i += bits[i] + 1 } return i == n-1 }
[sol1-JavaScript]
1 2 3 4 5 6 7
var isOneBitCharacter = function(bits) { let i = 0, n = bits.length; while (i < n - 1) { i += bits[i] + 1; } return i === n - 1; };
[sol1-C]
1 2 3 4 5 6 7
boolisOneBitCharacter(int* bits, int bitsSize){ int i = 0; while (i < bitsSize - 1) { i += bits[i] + 1; } return i == bitsSize - 1; }