You are viewing a single comment's thread. Return to all comments →
No DP, No recursion, O(n) solution
static boolean solve(int s, int e) { int c = 0; for (int i = s; i < e; i++) { if ((a[i] == 1 && b[i] == 1) || (i - 1 >= 0 && a[i] == 1 && b[i - 1] == 1)) { if (c % 2 != 0) return false; else c = 0; } if (a[i] != 1) c++; if (b[i] != 1) c++; } if (c % 2 != 0) return false; else return true; }
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 →
No DP, No recursion, O(n) solution