leetcode
文章平均质量分 68
macans
止步就是退步
展开
-
LeetCode----best-time-to-buy-and-sell-stock-ii
题目描述Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you原创 2016-10-09 22:09:03 · 350 阅读 · 0 评论 -
evaluate-reverse-polish-notation(逆波兰表示求值)
//atoi (表示 ascii to integer)是把字符串转换成整型数:int atoi(const char *nptr);//string.c_str是Borland封装的String类中的一个函数,它返回当前字符串的首字符地址。class Solution {public: int evalRPN(vector &tokens) {原创 2016-09-21 22:10:02 · 455 阅读 · 0 评论 -
Minimum Depth of Binary Tree(求二叉树的最小深度)
class Solution {public: int run(TreeNode *root) { if (root==NULL){ return 0; } int l = run(root->left); int r = run(root->right); if (l原创 2016-09-21 21:54:53 · 417 阅读 · 0 评论 -
LeetCode----best-time-to-buy-and-sell-stock-iii
题目描述Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at mosttwo transactions.原创 2016-10-13 12:29:54 · 566 阅读 · 0 评论 -
LeetCode----sum-root-to-leaf-numbers
题目描述Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find原创 2016-10-16 11:16:34 · 365 阅读 · 0 评论 -
LeetCode----path-sum
题目描述Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below bina原创 2016-10-16 11:41:28 · 356 阅读 · 0 评论 -
LeetCode----word-ladder
题目描述Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach int原创 2016-10-18 13:12:15 · 457 阅读 · 0 评论 -
LeetCode-----------gas-station
There are N gas stations along a circular route, where the amount of gas at station i isgas[i].You have a car with an unlimited gas tank and it costscost[i]of gas to travel from station i to its n原创 2016-10-04 16:49:12 · 485 阅读 · 0 评论 -
LeetCode------------palindrome-partitioning(回文)
题目描述Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s ="aab",Retu原创 2016-10-05 11:46:39 · 321 阅读 · 0 评论 -
LeetCode----count-and-say
题目描述The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"two 1s"or21.21is read off原创 2016-10-18 21:48:10 · 352 阅读 · 0 评论 -
LeetCode:word-breakII
题目描述Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For examp原创 2016-10-06 09:10:48 · 260 阅读 · 0 评论 -
LeetCode--------candy
题目描述There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must原创 2016-10-06 19:39:03 · 450 阅读 · 0 评论 -
max-points-on-a-line
求二维共线的最多点数原创 2016-09-22 21:19:02 · 380 阅读 · 0 评论 -
Sort a linked list in O(n log n) time using constant space complexity.
快排,归并排序 实现链表排序。原创 2016-09-23 10:34:49 · 615 阅读 · 0 评论 -
insertion-sort-list
Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {原创 2016-09-23 13:52:33 · 308 阅读 · 0 评论 -
LeetCode----best-time-to-buy-and-sell-stock
题目描述Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one shar原创 2016-10-09 19:40:40 · 321 阅读 · 0 评论 -
LeetCode----surrounded-regions
题目描述Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region .For example,X X X XX原创 2016-10-13 09:23:59 · 415 阅读 · 0 评论 -
LeetCode------------palindrome-partitioningII(回文2)
题目描述Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s原创 2016-10-05 16:09:49 · 330 阅读 · 0 评论 -
LeetCode------------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 u原创 2016-10-04 14:39:03 · 334 阅读 · 0 评论 -
LeetCode--------single-number
题目描述Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. 1原创 2016-10-04 14:10:09 · 380 阅读 · 0 评论 -
LeetCode---------copy-list-with-random-pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.继续挑战提交的代码 语言:C原创 2016-10-04 13:31:46 · 339 阅读 · 0 评论 -
LeetCode:word-break
题目描述Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens ="leetcode",原创 2016-09-27 12:37:13 · 426 阅读 · 0 评论 -
linked-list-cycle-ii
空间限制:32768K本题知识点: 链表 leetcode 算法知识视频讲解题目描述Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without转载 2016-09-26 21:04:29 · 371 阅读 · 0 评论 -
binary-tree-preorder-traversal(先序遍历二叉树)
非递归实现二叉树的先序遍历原创 2016-09-25 12:34:05 · 527 阅读 · 0 评论 -
reorder-list
单链表重排原创 2016-09-25 13:52:53 · 679 阅读 · 0 评论 -
binary-tree-postorder-traversal(后序遍历二叉树)
递归和非递归方法实现二叉树的后序遍历。原创 2016-09-25 12:08:05 · 503 阅读 · 0 评论 -
LeetCode------clone-graph
题目描述Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use#as a sepa原创 2016-10-07 15:59:03 · 390 阅读 · 0 评论