C++ check A[0] and B[0]
We are as good as our very first domino :) So, we just need to check for A[0] (top) and B[0] (bot).\n\nIf we find a domino that does not have top or bot, then w
We are as good as our very first domino :) So, we just need to check for A[0] (```top```) and B[0] (```bot```).\n\nIf we find a domino that does not have ```top``` or ```bot```, then we exclude that number from consideration. We count how many times a number appear in the top or bottom of each domino and use these numbers to detect the minimum number of flips.\n```\nint minDominoRotations(vector<int>& A, vector<int>& B) {\n  auto top = A[0], bot = B[0], top1 = 0, bot1 = 0, top2 = 0, bot2 = 0;\n  for (auto i = 0; i < A.size(); ++i) {\n    if (A[i] != top && B[i] != top) top = 0;\n    if (A[i] != bot && B[i] != bot) bot = 0;\n    top1 += A[i] == top;\n    bot1 += B[i] == top;\n    top2 += A[i] == bot;\n    bot2 += B[i] == bot;\n  }\n  return top || bot ? min(A.size() - max(top1, bot1), A.size() - max(top2, bot2)) : -1;\n}\n```
[]