Posted on 2023-04-27 21:49
Uriel 閱讀(54)
評論(0) 編輯 收藏 引用 所屬分類:
數(shù)學(xué) 、
閑來無事重切Leet Code
有n個燈泡,開始全部點亮,然后一次關(guān)閉/電量2的倍數(shù)、3的倍數(shù)...n的倍數(shù),問最后剩下幾個燈
看了Discussion才明白->https://leetcode.com/problems/bulb-switcher/solutions/3459201
1 #319
2 #Runtime: 17 ms (Beats 49.15%)
3 #Memory: 13.2 MB (Beats 91.53%)
4
5 class Solution(object):
6 def bulbSwitch(self, n):
7 """
8 :type n: int
9 :rtype: int
10 """
11 return int(sqrt(n))