有n個(gè)燈泡,開(kāi)始全部點(diǎn)亮,然后一次關(guān)閉/電量2的倍數(shù)、3的倍數(shù)...n的倍數(shù),問(wèn)最后剩下幾個(gè)燈
看了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))