![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode 题解
快乐松鼠蹦蹦跳
这个作者很懒,什么都没留下…
展开
-
Evaluate Reverse Polish Notation
Evaluate Reverse Polish Notation Total Accepted: 17802 Total Submissions: 90675My SubmissionsEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators a原创 2014-07-22 09:49:42 · 468 阅读 · 0 评论 -
leetcode Gas Station
Gas Station Total Accepted: 19381 Total Submissions: 75345My SubmissionsThere 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 · 704 阅读 · 0 评论 -
Palindrome Partitioning leetcode
Palindrome Partitioning Total Accepted: 18096 Total Submissions: 69797My SubmissionsGiven a string s, partition s such that every substring of the partition is a palindrome.Return all原创 2014-09-09 16:01:49 · 655 阅读 · 0 评论 -
leetcode Palindrome Partitioning II
这道题目,对于O(n^2)求出所有的回文字串,必须用dp的方法。原创 2014-09-09 21:10:30 · 509 阅读 · 0 评论 -
leetcode Valid Palindrome
回文串的判断原创 2014-09-12 20:28:53 · 600 阅读 · 0 评论 -
leetcode Triangle
Triangle Total Accepted: 17742 Total Submissions: 66191My SubmissionsGiven 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 · 545 阅读 · 0 评论 -
leetcode Longest Consecutive Sequence
获取一个数组当中,最长连续数字原创 2014-09-12 20:06:30 · 616 阅读 · 0 评论 -
Binary Tree Maximum Path Sum
数当中路径的最大和原创 2014-09-12 20:43:30 · 634 阅读 · 0 评论 -
leetcode Pascal's Triangle II
Pascal's Triangle II Total Accepted: 16710 Total Submissions: 54790My SubmissionsGiven 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 · 666 阅读 · 0 评论 -
leetcode Word Ladder
以单词为节点的图的搜索。原创 2014-09-12 20:16:02 · 624 阅读 · 0 评论 -
leetcode Surrounded Regions
层次扫描结合广度优先搜索原创 2014-09-12 19:46:21 · 627 阅读 · 0 评论 -
leetcode Best Time to Buy and Sell Stock II
Best Time to Buy and Sell Stock II Total Accepted: 22750 Total Submissions: 61772My SubmissionsSay 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 · 559 阅读 · 0 评论 -
leetcode Sum Root to Leaf Numbers
树的简单递归。原创 2014-09-12 20:01:44 · 565 阅读 · 0 评论 -
leetcode Best Time to Buy and Sell Stock
Best Time to Buy and Sell Stock Total Accepted: 22896 Total Submissions: 73662My SubmissionsSay 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 · 519 阅读 · 0 评论 -
leetcode Clone Graph
Clone Graph Total Accepted: 16482 Total Submissions: 72324My SubmissionsClone 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 · 752 阅读 · 0 评论 -
leetcode Candy
Candy Total Accepted: 17540 Total Submissions: 92484My SubmissionsThere 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 · 785 阅读 · 0 评论 -
Linked List Cycle II
Linked List Cycle II Total Accepted: 17710 Total Submissions: 57697My SubmissionsGiven 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 · 507 阅读 · 0 评论 -
Max Points on a Line
Max Points on a Line Total Accepted: 13981 Total Submissions: 130605My SubmissionsGiven 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 · 523 阅读 · 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 · 510 阅读 · 0 评论 -
leetcode Binary Tree Postorder Traversal
Binary Tree Postorder Traversal Total Accepted: 23892 Total Submissions: 77206My SubmissionsGiven a binary tree, return the postorder traversal of its nodes' values.For example:Given原创 2014-08-01 15:36:41 · 431 阅读 · 0 评论 -
Word Break
Word Break Total Accepted: 18345 Total Submissions: 88544My SubmissionsGiven 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 · 533 阅读 · 0 评论 -
Copy List with Random Pointer
Copy List with Random Pointer Total Accepted: 15399 Total Submissions: 67259My SubmissionsA linked list is given such that each node contains an additional random pointer which could poi原创 2014-08-02 10:39:45 · 468 阅读 · 0 评论 -
Single Number II
Single Number IIGiven 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 · 740 阅读 · 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 · 619 阅读 · 0 评论 -
Single Number
Single Number Total Accepted: 28603 Total Submissions: 62862My SubmissionsGiven an array of integers, every element appears twice except for one. Find that single one.Note:Your algor原创 2014-08-02 11:23:17 · 437 阅读 · 0 评论 -
Sort List leetcode
Sort List Total Accepted: 16300 Total Submissions: 79978My SubmissionsSort 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 · 531 阅读 · 0 评论 -
Linked List Cycle
Linked List Cycle Total Accepted: 24397 Total Submissions: 68598My SubmissionsGiven 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 · 672 阅读 · 0 评论 -
Leetcode LRU Cache
LRU Cache Total Accepted: 14047 Total Submissions: 103807My SubmissionsDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operatio原创 2014-08-01 14:09:45 · 518 阅读 · 0 评论 -
Binary Tree Preorder Traversal
Binary Tree Preorder Traversal Total Accepted: 26399 Total Submissions: 74449My SubmissionsGiven a binary tree, return the preorder traversal of its nodes' values.For example:Given b原创 2014-08-01 15:41:57 · 496 阅读 · 0 评论 -
Reorder List
Reorder List Total Accepted: 15732 Total Submissions: 78041My SubmissionsGiven 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 · 387 阅读 · 0 评论 -
leetcode Pascal's Triangle
Pascal's Triangle Total Accepted: 18780 Total Submissions: 59362My SubmissionsGiven numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[原创 2014-09-12 21:31:57 · 524 阅读 · 0 评论