
leetcode 题解
快乐松鼠蹦蹦跳
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Evaluate Reverse Polish Notation
Evaluate Reverse Polish Notation Total Accepted: 17802 Total Submissions: 90675My Submissions Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators a原创 2014-07-22 09:49:42 · 504 阅读 · 0 评论 -
leetcode Gas Station
Gas Station Total Accepted: 19381 Total Submissions: 75345My Submissions There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car w原创 2014-09-09 15:39:50 · 751 阅读 · 0 评论 -
Palindrome Partitioning leetcode
Palindrome Partitioning Total Accepted: 18096 Total Submissions: 69797My Submissions Given a string s, partition s such that every substring of the partition is a palindrome. Return all原创 2014-09-09 16:01:49 · 706 阅读 · 0 评论 -
leetcode Palindrome Partitioning II
这道题目,对于O(n^2)求出所有的回文字串,必须用dp的方法。原创 2014-09-09 21:10:30 · 549 阅读 · 0 评论 -
leetcode Valid Palindrome
回文串的判断原创 2014-09-12 20:28:53 · 639 阅读 · 0 评论 -
leetcode Triangle
Triangle Total Accepted: 17742 Total Submissions: 66191My Submissions Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row原创 2014-09-12 21:15:37 · 595 阅读 · 0 评论 -
leetcode Longest Consecutive Sequence
获取一个数组当中,最长连续数字原创 2014-09-12 20:06:30 · 650 阅读 · 0 评论 -
Binary Tree Maximum Path Sum
数当中路径的最大和原创 2014-09-12 20:43:30 · 686 阅读 · 0 评论 -
leetcode Pascal's Triangle II
Pascal's Triangle II Total Accepted: 16710 Total Submissions: 54790My Submissions Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,原创 2014-09-12 21:34:03 · 719 阅读 · 0 评论 -
leetcode Word Ladder
以单词为节点的图的搜索。原创 2014-09-12 20:16:02 · 663 阅读 · 0 评论 -
leetcode Surrounded Regions
层次扫描结合广度优先搜索原创 2014-09-12 19:46:21 · 670 阅读 · 0 评论 -
leetcode Best Time to Buy and Sell Stock II
Best Time to Buy and Sell Stock II Total Accepted: 22750 Total Submissions: 61772My Submissions Say you have an array for which the ith element is the price of a given stock on day i. De原创 2014-09-12 21:13:32 · 601 阅读 · 0 评论 -
leetcode Sum Root to Leaf Numbers
树的简单递归。原创 2014-09-12 20:01:44 · 605 阅读 · 0 评论 -
leetcode Best Time to Buy and Sell Stock
Best Time to Buy and Sell Stock Total Accepted: 22896 Total Submissions: 73662My Submissions Say you have an array for which the ith element is the price of a given stock on day i. If yo原创 2014-09-12 21:10:37 · 560 阅读 · 0 评论 -
leetcode Clone Graph
Clone Graph Total Accepted: 16482 Total Submissions: 72324My Submissions Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirect原创 2014-09-09 15:52:39 · 797 阅读 · 0 评论 -
leetcode Candy
Candy Total Accepted: 17540 Total Submissions: 92484My Submissions There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these childre原创 2014-09-09 15:40:14 · 830 阅读 · 0 评论 -
Linked List Cycle II
Linked List Cycle II Total Accepted: 17710 Total Submissions: 57697My Submissions Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow u原创 2014-08-01 16:43:05 · 543 阅读 · 0 评论 -
Max Points on a Line
Max Points on a Line Total Accepted: 13981 Total Submissions: 130605My Submissions Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.原创 2014-07-22 14:50:09 · 566 阅读 · 0 评论 -
Reverse Words in a String
class Solution { public: vector res; void reverseWords(string &s) { int len = s.size(); int i =0,j = 0; for(i=len-1;i>=0;i--) { while(i>=0 && s[i]==原创 2014-07-22 09:45:28 · 543 阅读 · 0 评论 -
leetcode Binary Tree Postorder Traversal
Binary Tree Postorder Traversal Total Accepted: 23892 Total Submissions: 77206My Submissions Given a binary tree, return the postorder traversal of its nodes' values. For example: Given原创 2014-08-01 15:36:41 · 465 阅读 · 0 评论 -
Word Break
Word Break Total Accepted: 18345 Total Submissions: 88544My Submissions Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of原创 2014-08-01 21:04:18 · 589 阅读 · 0 评论 -
Copy List with Random Pointer
Copy List with Random Pointer Total Accepted: 15399 Total Submissions: 67259My Submissions A linked list is given such that each node contains an additional random pointer which could poi原创 2014-08-02 10:39:45 · 502 阅读 · 0 评论 -
Single Number II
Single Number II Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?原创 2014-08-02 11:20:06 · 779 阅读 · 0 评论 -
Word Break II
Word Break Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a va原创 2014-08-01 20:22:12 · 660 阅读 · 0 评论 -
Single Number
Single Number Total Accepted: 28603 Total Submissions: 62862My Submissions Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algor原创 2014-08-02 11:23:17 · 471 阅读 · 0 评论 -
Sort List leetcode
Sort List Total Accepted: 16300 Total Submissions: 79978My Submissions Sort a linked list in O(n log n) time using constant space complexity. Have you been asked this que原创 2014-07-30 21:19:01 · 566 阅读 · 0 评论 -
Linked List Cycle
Linked List Cycle Total Accepted: 24397 Total Submissions: 68598My Submissions Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra sp原创 2014-08-01 16:51:27 · 714 阅读 · 0 评论 -
Leetcode LRU Cache
LRU Cache Total Accepted: 14047 Total Submissions: 103807My Submissions Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operatio原创 2014-08-01 14:09:45 · 553 阅读 · 0 评论 -
Binary Tree Preorder Traversal
Binary Tree Preorder Traversal Total Accepted: 26399 Total Submissions: 74449My Submissions Given a binary tree, return the preorder traversal of its nodes' values. For example: Given b原创 2014-08-01 15:41:57 · 534 阅读 · 0 评论 -
Reorder List
Reorder List Total Accepted: 15732 Total Submissions: 78041My Submissions Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place原创 2014-08-01 16:13:40 · 418 阅读 · 0 评论 -
leetcode Pascal's Triangle
Pascal's Triangle Total Accepted: 18780 Total Submissions: 59362My Submissions Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [原创 2014-09-12 21:31:57 · 574 阅读 · 0 评论