344、反转字符串 classSolution: defreverseString(self,s:List[str])->None: """ Donotreturnanyth...
344、反转字符串 classSolution: defreverseString(self,s:List[str])->None: """ Donotreturnanyth...
237、删除链表中的节点 #Definitionforsingly-linkedlist. #classListNode: #def__init__(self,x): #se...
231、2的幂 classSolution: defisPowerOfTwo(self,n:int)->bool: returnn>0andnot(n&(n-1)) 235、...
215、数组中的第k个最大元素 classSolution: deffindKthLargest(self,nums:List[int],k:int)->int: iflen...
160、相交链表 #Definitionforsingly-linkedlist. #classListNode: #def__init__(self,x): #self.v...
146.lru缓存机制 classDNode: def__init__(self,key=0,value=0,prev=None,next=None): self.key=k...
136、只出现一次的数字 classSolution: defsingleNumber(self,nums:List[int])->int: a=0 fornuminnums...
121、买股票的最佳时机 classSolution: defmaxProfit(self,prices:List[int])->int: min_p,max_p=99999...
88、合并两个有序数组 classSolution: defmerge(self,nums1:List[int],m:int,nums2:List[int],n:int)->...
62、不同的路径 classSolution: defuniquePaths(self,m:int,n:int)->int: dp=[[0for_inrange(n)]for...
54、螺旋矩阵 classSolution: defspiralOrder(self,matrix:List[List[int]])->List[int]: ret=[] i...
43、字符串相乘 classSolution: defmultiply(self,num1:str,num2:str)->str: num1_len=len(num1) nu...
23、合并K个升序链表 #Definitionforsingly-linkedlist. #classListNode: #def__init__(self,val=0,ne...
16、最接近的三数之和 classSolution: defthreeSumClosest(self,nums:List[int],target:int)->int: n=l...
11、盛最多水的容器 classSolution: defmaxArea(self,height:List[int])->int: left=0 right=len(heig...
7、整数反转 classSolution: defreverse(self,x:int)->int: ifx==0: return0 str_x=str(x) x='' if...
两数相加 #Definitionforsingly-linkedlist. #classListNode: #def__init__(self,val=0,next=None...