上一页 1 2 3 4 5 6 7 ··· 10 下一页
摘要: #-*- coding: UTF-8 -*-#利用strip函数去掉字符串去除空格(其实是去除两边【左边和右边】空格)#利用split分离字符串成列表class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rt 阅读全文
posted @ 2016-11-13 19:19 火金队长 阅读(156) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :typ 阅读全文
posted @ 2016-11-13 19:18 火金队长 阅读(330) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-class Solution(object): def isPalindrome(self, head): """ :type head: ListNode :rtype: bool """ if head==None or head.next==None 阅读全文
posted @ 2016-11-13 19:18 火金队长 阅读(194) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#利用栈的思想#如果输入的左测扩则入栈,如果输入为右侧扩,判断其是否与当前栈顶配对,如果匹配则删除这一对,否则return False#'(', ')', '{', '}', '[' and ']'class Solution(object): def i 阅读全文
posted @ 2016-11-13 19:17 火金队长 阅读(254) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#遍历所有元素,将元素值当做键、元素下标当做值#存放在一个字典中。遍历的时候,#如果发现重复元素,则比较其下标的差值是否小于k,#如果小于则可直接返回True,否则更新字典中该键的值为新的下标class Solution(object): def cont 阅读全文
posted @ 2016-11-13 19:17 火金队长 阅读(204) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#先判断是否有重叠class Solution(object): def computeArea(self, A, B, C, D, E, F, G, H): """ :type A: int :type B: int :type C: int :type 阅读全文
posted @ 2016-11-13 19:16 火金队长 阅读(146) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-class Solution(object): def wordPattern(self, pattern, str): """ :type pattern: str :type str: str :rtype: bool """ tag=0 tagdic 阅读全文
posted @ 2016-11-13 19:15 火金队长 阅读(147) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#双指针思想,两个指针相隔n-1,每次两个指针向后一步,当后面一个指针没有后继了,前面一个指针的后继就是要删除的节点# Definition for singly-linked list.# class ListNode(object):# def __i 阅读全文
posted @ 2016-11-13 19:14 火金队长 阅读(130) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- # Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.rig 阅读全文
posted @ 2016-11-13 19:13 火金队长 阅读(120) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- class Solution(object): def countAndSay(self, n): """ :type n: int :rtype: str """ n=n-1 if n==0:return str(1) tag=1;stri=str(1 阅读全文
posted @ 2016-11-13 19:13 火金队长 阅读(220) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 10 下一页