Skip to content

Commit 8c90bdb

Browse files
authored
Create bulb-switcher-ii.cpp
1 parent aa61036 commit 8c90bdb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

C++/bulb-switcher-ii.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Time: O(1)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int flipLights(int n, int m) {
7+
if (m == 0) return 1;
8+
if (n == 1) return 2;
9+
if (m == 1 && n == 2) return 3;
10+
if (m == 1 || n == 2) return 4;
11+
if (m == 2) return 7;
12+
return 8;
13+
}
14+
};

0 commit comments

Comments
 (0)