摘要:
#-*- coding: UTF-8 -*- # Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.rig 阅读全文
摘要:
#-*- coding: UTF-8 -*- class Solution(object): def findTheDifference(self, s, t): s=sorted(list(s)) t=sorted(list(t)) for st in s: p=t.index(st) del t 阅读全文
摘要:
#-*- coding: UTF-8 -*- from itertools import combinationsclass Solution(object): hourList=[8,4,2,1] minList=[32,16,8,4,2,1] def selectHour(self,hourNu 阅读全文
摘要:
#-*- coding: UTF-8 -*- class Solution(object): hexDic={0:'0',1:'1',2:'2',3:'3',4:'4',5:'5',6:'6',7:'7',8:'8',9:'9',\ 10:'a', 11:'b', 12:'c', 13:'d', 1 阅读全文
摘要:
#-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solu 阅读全文
摘要:
#Method1:动态规划##当有n个台阶时,可供选择的走法可以分两类:###1,先跨一阶再跨完剩下n-1阶;###2,先跨2阶再跨完剩下n-2阶。###所以n阶的不同走法的数目是n-1阶和n-2阶的走法数的和class Solution(object): def climbStairs(self, 阅读全文
摘要:
class Solution: # @param digits, a list of integer digits # @return a list of integer digits def plusOne(self, digits): carry=1 for i in range(len(dig 阅读全文
摘要:
#-*- coding: UTF-8 -*- from collections import Counterclass Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: int """ lopa=0 阅读全文
摘要:
#-*- coding: UTF-8 -*- class Solution(object): def firstUniqChar(self, s): s=s.lower() sList=list(s) numCdic={} for c in s: numCdic[c]=numCdic[c]+1 if 阅读全文
摘要:
#-*- coding: UTF-8 -*- class Solution(object): def intersect(self, nums1, nums2): if len(nums1)<len(nums2): tmp=nums1 nums1=nums2 nums2=tmp tmpdic={} 阅读全文