You are viewing a single comment's thread. Return to all comments →
My python3 example with O(n) complexity:
def hexagonalGrid(a, b): if ((a.count('1') + b.count('1')) % 2 != 0): return 'NO' white = 0 block = False for i in range(len(a)): if (a[i] == '1'): if block and white % 2 != 0: return 'NO' block = True elif (a[i] == '0'): block = False white += 1 if (b[i] == '1'): if block and white % 2 != 0: return 'NO' block = True elif (b[i] == '0'): block = False white += 1 return 'YES'
Seems like cookies are disabled on this browser, please enable them to open this website
Hexagonal Grid
You are viewing a single comment's thread. Return to all comments →
My python3 example with O(n) complexity: