#Etc

leetcode 46-> Permutations

 Givenacollectionof distinct integers,returnallpossiblepermutations.classSolution(object):defpermute(self,nums):""":typenums:List[int]:rtype:List...
代码星球 ·2020-08-09

leetcode 29-> Divide Two Integers without using multiplication, division and mod operator

 classSolution(object):defdivide(self,dividend,divisor):""":typedividend:int:typedivisor:int:rtype:int"""ispositive=Trueifdividend>0anddivisor<0:ispo...

leetcode 19-> Remove Nth Node From End of List

 #Definitionforsingly-linkedlist.#classListNode(object):#def__init__(self,x):#self.val=x#self.next=NoneclassSolution(object):defremoveNthFromEnd(self,head,...

leetcode 18-> 4Sum

 classSolution(object):deffourSum(self,nums,target):""":typenums:List[int]:typetarget:int:rtype:List[List[int]]"""l=len(nums)nums.sort()ifl<4:return[]re...
代码星球 ·2020-08-09

leetcode 17-> Letter Combinations of a Phone Number

 classSolution(object):defletterCombinations(self,digits):""":typedigits:str:rtype:List[str]"""ifdigits=="":return[]nums_to_letters={2:"abc",3:"def",4:"ghi...

leetcode 16-> 3Sum Closest

 Givenanarray nums of n integersandaninteger target,findthreeintegersin nums suchthatthesumisclosestto target.Retur...
代码星球 ·2020-08-09

leetcode 15-> 3Sum

 classSolution(object):defthreeSum(self,nums):res=[]nums.sort()foriinxrange(len(nums)-2):ifi>0andnums[i]==nums[i-1]:continuel,r=i+1,len(nums)-1whilel<...
代码星球 ·2020-08-09

leetcode 14-> Longest Common Prefix

 note:Allgiveninputsareinlowercaseletters a-z.classSolution(object):deflongestCommonPrefix(self,strs):""":typestrs:List[str]:rtype:str"""iflen(strs)==...

leetcode 13 -> Roman to Integer

 classSolution(object):defromanToInt(self,s):""":types:str:rtype:int"""lista={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}Value_sum=0last_Value=0for...
代码星球 ·2020-08-09

/etc/postfix下 main.cf 配置文件详解

转自:https://www.cnblogs.com/qianyuliang/p/6501531.htmlpostconf-n#别名数据库(postalias/newaliases命令生成) alias_database=hash:/etc/postfix/aliases#别名表,列出localmda所使用的...

leetcode 12 -> Integer to Roman

 classSolution(object):defintToRoman(self,num):""":typenum:int:rtype:str"""ifnum==0:return""ifnum>=1000:return"M"+self.intToRoman(num-1000)elifnum>=9...
代码星球 ·2020-08-09

leetcode 9 -> Palindrome Number

 classSolution(object):defisPalindrome(self,x):""":typex:int:rtype:bool"""s=str(x)if(s==s[::-1]):returnTrueelse:returnFalse ...
代码星球 ·2020-08-09

leetcode 5-> Longest Palindromic Substring

 classSolution(object):defget_f_l(self,s_length,s,list_all,last_d):max_l=0first_d=0last_d=0foriinrange(len(list_all)):if((i+1)==len(list_all)):breakforjinr...

leetcode 7-> Reverse Integer(32-bit signed integer)

 classSolution(object):defreverse(self,x):""":typex:int:rtype:int"""p=abs(x)rev=int(str(p)[::-1])if(x<0):if((-rev)<pow(-2,31)):return0else:return-(re...

leetcode 4-> Median of Two Sorted Arrays

 classSolution(object):defhb(self,list1,list2):result=[]whilelist1andlist2:iflist1[0]<list2[0]:result.append(list1[0])dellist1[0]else:result.append(list...
首页上一页...3738394041...下一页尾页