- 博客(43)
- 收藏
- 关注
原创 【LEETCODE】62-Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the
2015-11-30 22:10:03 557
原创 【LEETCODE】198-House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house
2015-11-30 20:27:25 554
原创 【LEETCODE】70-Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?http://www.zhihu.com/questio
2015-11-30 19:47:33 460
原创 【LEETCODE】83-Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given 1->1->2, return1->2.Given 1->1->2->3->3, return1->2->3.因为是排好序的链表,所以可以直接用p和p
2015-11-30 17:53:03 374
原创 【LEETCODE】13-Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.参考:http://www.bubuko.com/infodetail-367049.html罗马数字是阿拉伯数字传入之前使用的一种数码。罗马数字采用七
2015-11-30 17:08:08 446
原创 【LEETCODE】191-Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit integer ’11' has binary representation00000000
2015-11-30 16:06:28 640
原创 【LEETCODE】169-Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element alw
2015-11-28 10:47:19 530
原创 【LEETCODE】171-Excel Sheet Column Number
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...
2015-11-27 23:50:23 411
原创 【LEETCODE】220-Contains Duplicate III
Given an array of integers, find out whether there are two distinct indicesi and j in the array such that the difference between nums[i] andnums[j] is at most t and the difference between i and
2015-11-27 16:42:14 614
原创 【LEETCODE】219-Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference betweeni and j is at most k.
2015-11-27 15:45:56 500
转载 【LEETCODE】217-Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element
2015-11-27 14:59:25 509
原创 【LEETCODE】283-Move Zeroes
Given an array nums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your f
2015-11-27 14:11:44 426
原创 【LEETCODE】92-Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL,m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the fo
2015-11-26 17:54:19 547
转载 【LEETCODE】142-Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Note: Do not modify the linked list.Follow up:Can you solve it without using extra space?参考:
2015-11-26 16:19:20 431
原创 【LEETCODE】141-Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?参考:http://www.cnblogs.com/zuoyuan/p/3701639.html用快慢指针,因为fast指针移动的速度是slow
2015-11-24 20:11:25 842
原创 【LEETCODE】234-Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?参考:http://bookshadow.com/weblog/2015/07/10/leetcode-palindrome-linked-list
2015-11-24 20:02:31 449
原创 【LEETCODE】203-Remove Linked List Elements
Remove all elements from a linked list of integers that have valueval.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val = 6Return: 1 --> 2 --> 3 --> 4 --> 5# Definition for singl
2015-11-24 17:51:01 411
原创 【LEETCODE】206-Reverse Linked List
Reverse a singly linked list.迭代:# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Sol
2015-11-24 16:54:48 469
原创 【LEETCODE】237-Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value
2015-11-24 15:45:33 429
原创 【LEETCODE】292-Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the
2015-11-24 15:07:25 511
原创 【MachineLearning】数据挖掘中的分类和聚类的区别
参考:http://www.cnblogs.com/batys/p/3274138.html分类聚类是一种有指导的学习,即每个训练样本的数据对象已经有类标识,通过学习可以形成表达数据对象与类标识间对应的知识是根据样本数据形成的类知识并对源数据进行分类进而也可以预测未来数据的归类是一种无指导学习是在预先不知道欲划分类的情
2015-11-12 15:11:39 1574
原创 【TED】只需专注10分钟-Andy Puddicombe
Problem:if our mind is full of difficult and confusing emotions,we get stressedwe may miss out some important things to uswe are anxious when we are feeling about anxiousFact:there w
2015-11-11 22:58:05 1139
原创 【LEETCODE】105-Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.# Definition for a binary tree node.# class TreeNode(o
2015-11-11 14:07:49 592
翻译 【TED】处乱不惊-Daniel Levitin
http://open.163.com/movie/2015/12/6/R/MB71TCPEI_MB71TPC6R.htmlVocabulary:thermometer on the front porch 前廊的温度fumbling in my pockets 摸摸衣服兜a locksmith to show up 找一个锁匠desperate in a fre
2015-11-10 19:10:37 1599
原创 【LEETCODE】236-Lowest Common Ancestor of a Binary Tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes
2015-11-10 17:09:33 447
原创 【LEETCODE】106-Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.参考:https://github.com/kamyu104/LeetCode/blob/master/
2015-11-10 11:01:39 563
原创 【LEETCODE】109-Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.# Definition for singly-linked list.# class ListNode(object):# def __init__(sel
2015-11-09 17:16:00 635
原创 【LEETCODE】114-Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1
2015-11-06 19:16:09 639
原创 【Programming for Everybody】学习笔记
Programming for Everybody (Getting Started with Python)by University of MichiganCharles SeveranceDownload TextWranglerhttp://www.barebones.com/products/textwrangler/Use T
2015-11-06 11:56:05 13955
原创 【LEETCODE】199-Binary Tree Right Side View
Given a binary tree, imagine yourself standing on theright side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree, 1
2015-11-05 21:27:14 757
原创 【LEETCODE】173-Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and
2015-11-05 14:48:17 914
原创 【LEETCODE】108-Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):#
2015-11-04 20:17:48 547
原创 【LEETCODE】95-Unique Binary Search Trees II
Given n, generate all structurally uniqueBST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3
2015-11-04 10:28:34 434
原创 【LEETCODE】96-Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \
2015-11-03 22:07:33 506
原创 【LEETCODE】94-Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.
2015-11-03 19:00:31 479
原创 【LEETCODE】144-Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].参考:http://bookshadow.
2015-11-03 16:32:40 546
原创 【LEETCODE】145-Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solution i
2015-11-03 11:30:33 444
原创 数据结构-stack-学习笔记
http://interactivepython.org/courselib/static/pythonds/index.htmlProblem Solving with Algorithms and Data Structures 栈 stackWhat is a Stack? 是一种运算受限的线性表 限制是
2015-11-02 20:12:38 556
原创 【LEETCODE】107-Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7},
2015-11-02 19:23:09 546
原创 【LEETCODE】102-Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 /
2015-11-02 16:51:57 510
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人