Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b5ccb87

Browse files
✨feat: add 672
1 parent 047eb1f commit b5ccb87

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎LeetCode/671-680/672. 灯泡开关 II(中等).md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ function flipLights(n: number, k: number): number {
9292
else return k == 1 ? 4 : k == 2 ? 7 : 8;
9393
};
9494
```
95+
Python 3 代码:
96+
```Python
97+
class Solution:
98+
def flipLights(self, n: int, k: int) -> int:
99+
if k == 0:
100+
return 1
101+
if n == 1:
102+
return 2
103+
elif n == 2:
104+
return 3 if k == 1 else 4
105+
else:
106+
return 4 if k == 1 else 7 if k == 2 else 8
107+
```
95108
* 时间复杂度:$O(1)$
96109
* 空间复杂度:$O(1)$
97110

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /