摘要: 1. 题目描述 2. 代码 1 class Solution: 2 def isPowerOfThree(self, n: int) -> bool: 3 while n > 2 and n % 3 == 0: 4 n = n // 3 5 return n == 1 阅读全文
posted @ 2020-10-20 20:51 vv_869 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述 2. 代码 1 class Solution: 2 def countPrimes(self, n: int) -> int: 3 nfilter = [False] * n 4 count = 0 5 for i in range(2,n): 6 if nfilter[i]:#非素 阅读全文
posted @ 2020-10-20 20:41 vv_869 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述 2. 代码 1 class Solution: 2 def isHappy(self, n: int) -> bool: 3 s = set([n]) 4 while n != 1: 5 sn = str(n) 6 sums = 0 7 for i in range(len(sn)) 阅读全文
posted @ 2020-10-20 19:30 vv_869 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述 2. 代码 1 class Solution: 2 def reverse(self, x: int) -> int: 3 if x == 0: 4 return 0 5 operation = 1 6 if x < 0: 7 operation = -1 8 sx = str(x) 阅读全文
posted @ 2020-10-19 20:33 vv_869 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述 2. 代码 1 class Solution: 2 def mySqrt(self, x: int) -> int: 3 return int(x ** 0.5) 阅读全文
posted @ 2020-10-19 19:46 vv_869 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述 2. 代码 1 class Solution: 2 def trailingZeroes(self, n: int) -> int: 3 count = 0 4 while (n > 0): 5 count += n // 5 6 n = n // 5 7 return count 阅读全文
posted @ 2020-10-19 19:34 vv_869 阅读(65) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述 2. 代码 1 class Solution: 2 def titleToNumber(self, s: 'str') -> 'int': 3 s = s.upper() 4 n = len(s) 5 sums = 0 6 k = 0 7 for i in range(n-1,-1, 阅读全文
posted @ 2020-10-19 18:45 vv_869 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述 2. 代码_解法1 1 class Solution: 2 def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: 3 """ 4 Do not return anything, mod 阅读全文
posted @ 2020-10-17 16:41 vv_869 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述 2. 代码 1 class Solution: 2 def findUnsortedSubarray(self, nums: 'List[int]') -> int: 3 n = len(nums) 4 temp = sorted(nums) 5 start,end = 0,n-1 阅读全文
posted @ 2020-10-17 11:16 vv_869 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述 2. 代码 1 class Solution: 2 def moveZeroes(self, nums: 'List[int]') -> None: 3 """ 4 Do not return anything, modify nums in-place instead. 5 """ 阅读全文
posted @ 2020-10-16 16:02 vv_869 阅读(74) 评论(0) 推荐(0) 编辑