classSolution { publicintflipgame(int[] fronts, int[] backs) { Set<Integer> set = newHashSet<>(); intn= fronts.length, ans = Integer.MAX_VALUE; for (inti=0; i < n; ++i) { if (fronts[i] == backs[i]) set.add(fronts[i]); } for (int x : fronts) { if (!set.contains(x)) ans = Math.min(ans, x); } for (int x : backs) { if (!set.contains(x)) ans = Math.min(ans, x); } return ans == Integer.MAX_VALUE ? 0 : ans; } }