We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 65b7bd6 commit ea7b4e6Copy full SHA for ea7b4e6
scripts/algorithms/C/Card Flipping Game/Card Flipping Game.js
@@ -1,28 +1,29 @@
1
+// Runtime: 120 ms (Top 38.46%) | Memory: 44.7 MB (Top 61.54%)
2
var flipgame = function(fronts, backs) {
3
const MAX = Number.MAX_SAFE_INTEGER;
4
const n = fronts.length;
5
const set = new Set();
6
7
let min = MAX;
-
8
+
9
for (let i = 0; i < n; i++) {
10
const front = fronts[i];
11
const back = backs[i];
12
13
if (front === back) {
14
set.add(front);
15
}
16
17
18
19
20
21
22
if (front === back) continue;
23
24
if (!set.has(front)) min = Math.min(front, min);
25
if (!set.has(back)) min = Math.min(back, min);
26
27
28
return min === MAX ? 0 : min;
-};
29
+};
0 commit comments