02 2019 档案
摘要:class Solution: def diStringMatch(self, S: str) -> List[int]: A=[i for i in range(len(S)+1)] res = A for index,s in enumerate(S): if s is 'I': A[index
阅读全文
摘要:class Solution: def judgeCircle(self, moves: str) -> bool: u,d,l,r = 0,0,0,0 for move in moves: if move is 'U': u += 1 elif move is 'D': d += 1 elif m
阅读全文
摘要:class Solution: def calcu(self,ele:List[str],loc): index_p = [-1]*2 #只记录离R最近位置的p和B(左右) index_B = [-1]*2 left,right = 0,0 for i in range(len(ele)): if
阅读全文
摘要:class Solution: def flipAndInvertImage(self, A: List[List[int]]) -> List[List[int]]: for a in A: first = 0 last = len(a)-1 while first<last: a[first],
阅读全文
摘要:class Solution: def sortArrayByParity(self, A: List[int]) -> List[int]: first = 0 last = len(A)-1 while first<last: m = A[first] n = A[last] if (m&1 i
阅读全文
摘要:class Solution: def sortedSquares(self, A: List[int]) -> List[int]: sqr = [] for a in A: sqr.append((a)**2) return sorted(sqr) 184ms,15.2M 优化一: class
阅读全文
摘要:class Solution: def repeatedNTimes(self, A: List[int]) -> int: if len(A)&1 > 0: return -1 aa = set(A) bb = {} for a in aa: bb[a] = 0 for i in A: bb[i]
阅读全文
摘要:三、用numpy.pad()对图像进行填充及简单的图像处理 https://blog.csdn.net/wang454592297/article/details/80854996 三、用numpy.pad()对图像进行填充及简单的图像处理 https://blog.csdn.net/wang454
阅读全文
摘要:一、使用内置函数 def toLowerCase(self, str: 'str') -> 'str': return str.lower() 28ms,12.4M class Solution: def toLowerCase(self, str: 'str') -> 'str': res = '
阅读全文
摘要:class Solution: def numUniqueEmails(self, emails: 'List[str]') -> 'int': accept = [] for email in emails: local = email.split('@')[0] domain = email.s
阅读全文
摘要:You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of ston
阅读全文