随笔分类 - leetcode
摘要:class Solution(object): def romanToInt(self, s): """ :type s: str :rtype: int """ lista={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000} Valu...
阅读全文
摘要:class Solution(object): def intToRoman(self, num): """ :type num: int :rtype: str """ if num == 0: return "" if num >= 1000: ...
阅读全文
摘要:class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ s=str(x) if(s==s[::-1]): return True els...
阅读全文
摘要:class Solution(object): def get_f_l(self,s_length,s,list_all,last_d): max_l=0 first_d=0 last_d=0 for i in range(len(list_all)): if((i+1)==len(list_al...
阅读全文
摘要:class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ p=abs(x) rev=int(str(p)[::-1]) if(x(pow(2,31)-1)): ...
阅读全文
摘要:class Solution(object): def hb(self,list1,list2): result = [] while list1 and list2: if list1[0] < list2[0]: result.append(list1[0]) ...
阅读全文
摘要:class Solution(object): def addTwoNumbers(self, l1, l2): l3 = ListNode(0) current = l3 carry = 0 while l1 or l2: # 1,1 | None,1 | 1,None # Pad 0 if N...
阅读全文
摘要:class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ dictionary = dict() ...
阅读全文
摘要:class Solution(object): def lengthOfLongestSubstring(self, s): d = "" f = "" for i in range(len(s)): if s[i] not in f: f += s[i] ...
阅读全文