Category Archives: Codility

Codility BinaryGap Solution C#

By | November 7, 2017

Codility BinaryGap Solution C# Find the longest sequence of zeros in binary representation of an integer. Solution: public int GetBinaryGap(int N) { string binaryValue = Convert.ToString(N, 2); int longestBinaryGap = 0; int binaryGapLenght = 0; for (int i = 1; i & lt; binaryValue.Length; i++) { if (binaryValue[i – 1] == ‘1’ && binaryValue[i] ==… Read More »