上一页 1 2 3 4 5 6 ··· 10 下一页
摘要: #-*- coding: UTF-8 -*- #l1 = ['1','3','2','3','2','1','1']#l2 = sorted(sorted(set(l1),key=l1.index,reverse=False),reverse=True)class Solution(object): 阅读全文
posted @ 2016-11-13 19:25 火金队长 阅读(249) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- #题意:大海捞刀,在长字符串中找出短字符串#AC源码:滑动窗口双指针的方法class Solution(object): def strStr(self, hayStack, needle): """ :type haystack: str :type 阅读全文
posted @ 2016-11-13 19:24 火金队长 阅读(236) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- class Solution: # @param n, an integer # @return an integer def reverseBits(self, n): tmp=str(bin(n))[2:][::-1] for i in xrange 阅读全文
posted @ 2016-11-13 19:23 火金队长 阅读(214) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- #AC源码【意外惊喜,还以为会超时】class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: L 阅读全文
posted @ 2016-11-13 19:23 火金队长 阅读(157) 评论(0) 推荐(0) 编辑
摘要: class Solution(object): def addBinary(self, a, b): """ :type a: str :type b: str :rtype: str """ resA=int(a,base=2) resB=int(b,base=2) sumAB=bin(resA+ 阅读全文
posted @ 2016-11-13 19:22 火金队长 阅读(239) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- #超时# lenA=len(A)# maxSum=[]# count=0# while count<lenA:# tmpSum=0# for i in xrange(lenA):# tmpSum+=i*A[i-count]# maxSum.append( 阅读全文
posted @ 2016-11-13 19:22 火金队长 阅读(245) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- class Solution(object): def findNthDigit(self, n): """ :type n: int :rtype: int """ res=n if n>9: index=1 mul=9 res=0 while Tru 阅读全文
posted @ 2016-11-13 19:21 火金队长 阅读(421) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- #两种方法#方法1:#计算出A和B两个链表的长度分别为m、n;#长度长的链表先走m-n步,之后再一次遍历寻找#方法2:#先走到一个链表的尾部,从尾部开始走;#跳到另一个链表的头部#如果相遇,则相遇点为重合节点class Solution(object): 阅读全文
posted @ 2016-11-13 19:21 火金队长 阅读(608) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solu 阅读全文
posted @ 2016-11-13 19:20 火金队长 阅读(267) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-class Stack(object): def __init__(self): """ initialize your data structure here. """ self.inQueue=[] self.outQueue=[] def push( 阅读全文
posted @ 2016-11-13 19:19 火金队长 阅读(191) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 10 下一页