We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7569b25 commit a3956f8Copy full SHA for a3956f8
C++/card-flipping-game.cpp
@@ -0,0 +1,26 @@
1
+// Time: O(n)
2
+// Space: O(n)
3
+
4
+class Solution {
5
+public:
6
+ int flipgame(vector<int>& fronts, vector<int>& backs) {
7
+ unordered_set<int> same;
8
+ for (int i = 0; i < fronts.size(); ++i) {
9
+ if (fronts[i] == backs[i]) {
10
+ same.emplace(fronts[i]);
11
+ }
12
13
+ int result = numeric_limits<int>::max();
14
+ for (const auto& n : fronts) {
15
+ if (!same.count(n)) {
16
+ result = min(result, n);
17
18
19
+ for (const auto& n : backs) {
20
21
22
23
24
+ return result != numeric_limits<int>::max() ? result : 0;
25
26
+};
0 commit comments