上一页 1 2 3 4 5 6 7 8 ··· 10 下一页
摘要: #-*- coding: UTF-8 -*- #转换法class Solution(object): def isIsomorphic(self, s, t): """ :type s: str :type t: str :rtype: bool """ sdic={} slist=[] tdic= 阅读全文
posted @ 2016-11-13 19:12 火金队长 阅读(170) 评论(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.righ 阅读全文
posted @ 2016-11-13 19:11 火金队长 阅读(148) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-class Solution(object): def getHint(self, secret, guess): """ :type secret: str :type guess: str :rtype: str """ countA,i,numLis 阅读全文
posted @ 2016-11-13 19:08 火金队长 阅读(261) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#特定的九个格内1-9的个数至多为1#依次检查每行,每列,每个子九宫格是否出现重复元素,如果出现返回false,否则返回true.class Solution(object): def isValidSudoku(self, board): """ :ty 阅读全文
posted @ 2016-11-13 19:07 火金队长 阅读(157) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-# The guess API is already defined for you.# @param num, your guess# @return -1 if my number is lower, 1 if my number is higher, 阅读全文
posted @ 2016-11-13 19:07 火金队长 阅读(154) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#需要考虑多种情况#以下几种是可以返回的数值#1、以0开头的字符串,如01201215#2、以正负号开头的字符串,如‘+121215’;‘-1215489’#3、1和2和空格混合形式【顺序只能是正负号-0,空格位置可以随意】的:‘+00121515’#4、 阅读全文
posted @ 2016-11-13 19:04 火金队长 阅读(802) 评论(0) 推荐(0) 编辑
摘要: class Solution(object): def findAnagrams(self, s, p): """ :type s: str :type p: str :rtype: List[int] """ reslist=[];sdic={};pdic={} ls=len(s) lp=len( 阅读全文
posted @ 2016-10-31 18:46 火金队长 阅读(868) 评论(0) 推荐(0) 编辑
摘要: class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void 阅读全文
posted @ 2016-10-31 18:45 火金队长 阅读(186) 评论(0) 推荐(0) 编辑
摘要: #栈是先进后出 #队列先进先出 class Stack(object): def __init__(self): """ initialize your data structure here. """ self.inQueue=[] self.outQueue=[] def push(self, 阅读全文
posted @ 2016-10-31 18:43 火金队长 阅读(220) 评论(0) 推荐(0) 编辑
摘要: #很简单,利用strip函数去除左右两边的空格,然后用split函数分割成列表 class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ if s==None:return 0 sl 阅读全文
posted @ 2016-10-31 18:42 火金队长 阅读(93) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 10 下一页