解法四:解法三的 while 写法(LeetCode 官方解法) class Solution: def isThree(self, n: int) -> bool: count=0 i=1 while i*i<=n: ## 不用sqrt函数 if n%i==0: if i!=n/i: ## // 整除也是可以的 count+=2 else: count+=1 i+=1 return count==3 以上解法的时间复杂度: 从1 遍历到...
Github 同步地址: https://github.com/grandyang/leetcode/issues/1363 参考资料: https://leetcode.com/problems/largest-multiple-of-three/ https://leetcode.com/problems/largest-multiple-of-three/solutions/532860/simple-solution-with-brief-explanation-time-o-n-space-o-10-constant/ LeetCode All in O...