摘要:
#coding=utf-8#点评:#递归思想加层次遍历,很经典的解题模板思想 20181220class Solution(object): def numSquares(self, n): """ :type n: int :rtype: int """ pair = (n,0) queue = 阅读全文
posted @ 2019-03-17 16:18
AceKo
阅读(195)
评论(0)
推荐(0)
摘要:
# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution 阅读全文
posted @ 2019-03-17 16:17
AceKo
阅读(87)
评论(0)
推荐(0)
摘要:
class Solution(object): def evalRPN(self, tokens): """ :type tokens: List[str] :rtype: int """ stack = [] ops = ["+","-","*","/"] for i in tokens: if 阅读全文
posted @ 2019-03-17 16:16
AceKo
阅读(127)
评论(0)
推荐(0)
摘要:
class Solution(object): def postorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] """ class Command(object): def __init__(self,co 阅读全文
posted @ 2019-03-17 16:15
AceKo
阅读(151)
评论(0)
推荐(0)
摘要:
# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution 阅读全文
posted @ 2019-03-17 16:14
AceKo
阅读(88)
评论(0)
推荐(0)
摘要:
# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution 阅读全文
posted @ 2019-03-17 16:10
AceKo
阅读(201)
评论(0)
推荐(0)
摘要:
# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution 阅读全文
posted @ 2019-03-17 16:09
AceKo
阅读(206)
评论(0)
推荐(0)
摘要:
class Solution(object): def ladderLength(self, beginWord, endWord, wordList): """ :type beginWord: str :type endWord: str :type wordList: List[str] :r 阅读全文
posted @ 2019-03-17 16:08
AceKo
阅读(166)
评论(0)
推荐(0)
摘要:
class Solution(object): def findLadders(self, beginWord, endWord, wordlist): """ :type beginWord: str :type endWord: str :type wordlist: Set[str] :rty 阅读全文
posted @ 2019-03-17 16:03
AceKo
阅读(118)
评论(0)
推荐(0)
摘要:
# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution 阅读全文
posted @ 2019-03-17 16:02
AceKo
阅读(95)
评论(0)
推荐(0)
摘要:
# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution 阅读全文
posted @ 2019-03-17 16:01
AceKo
阅读(189)
评论(0)
推荐(0)
摘要:
# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution 阅读全文
posted @ 2019-03-17 16:00
AceKo
阅读(210)
评论(0)
推荐(0)
摘要:
class Solution(object): def inorderTraversal(self, root): """ :type root: TreeNode :rtype """ res = [] self.order(root, res) return res def order(self 阅读全文
posted @ 2019-03-17 15:58
AceKo
阅读(128)
评论(0)
推荐(0)
摘要:
class Solution(object): def inorderTraversal(self, root): """ :type root: TreeNode :rtype """ class Command(object): def __init__(self,com,node): self 阅读全文
posted @ 2019-03-17 15:58
AceKo
阅读(153)
评论(0)
推荐(0)
摘要:
#coding=utf-8#看到这种来来回回,增增删删的题,一般都想到用栈。#我们把字符串按照/分割之后就得到了每个文件的目录,然后判断路径是添加还是向上层进行返回。这个题很简单了。#有一个地方犯了小错误,不能写成if dir == ‘..’ and stack: stack.pop()。这样的话如 阅读全文
posted @ 2019-03-17 15:57
AceKo
阅读(79)
评论(0)
推荐(0)
摘要:
# Definition for singly-linked list.class ListNode(object): def __init__(self, x): self.val = x self.next = Noneclass Solution(object): def mergeKList 阅读全文
posted @ 2019-03-17 15:56
AceKo
阅读(86)
评论(0)
推荐(0)
摘要:
#coding=utf-8# 解题思路:栈 20190302 找工作期间class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ stack = [] for i in s : if i == "( 阅读全文
posted @ 2019-03-17 15:55
AceKo
阅读(108)
评论(0)
推荐(0)
摘要:
# 1、在有序表中查找两数组指定的和,双指针法# 2、滑动窗口 : 连续子数组之和# 3、二分查找 : 顺序数组中查找特定的值# 4、递归程序的真正的构建是从底向上的,这就是为什么递归终止条件要写在最前面# 参见 反转链表的递归程序 LeetCode206# 5、 链表归并排序的递归过程,要好好体会 阅读全文
posted @ 2019-03-17 14:46
AceKo
阅读(481)
评论(0)
推荐(0)
摘要:
# 解题思路:字典存储计数信息 20190302 找工作期间class Solution(object): def fourSumCount(self, A, B, C, D): res2 = {} res = 0 for i in C: for j in D: res2[i + j] = res2 阅读全文
posted @ 2019-03-17 14:45
AceKo
阅读(104)
评论(0)
推荐(0)
摘要:
# 解题思路:字典存储计数信息 20190302 找工作期间class Solution(object): def frequencySort(self, s): """ :type s: str :rtype: str """ dict1 = {} result = str() for i in 阅读全文
posted @ 2019-03-17 14:44
AceKo
阅读(139)
评论(0)
推荐(0)