LeetCode
文章平均质量分 58
tony00fang
这个作者很懒,什么都没留下…
展开
-
[LeetCode]Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i原创 2014-05-17 09:33:16 · 490 阅读 · 0 评论 -
[LeetCode]Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.本题关键是原创 2014-05-16 14:29:05 · 480 阅读 · 0 评论 -
[LeetCode]Reverse Words in a String
#include #include #include using namespace std;class Solution{public: void reverseWords(string &s) { string st; for (int i = s.length() - 1; i >= 0;) { while (i >= 0 && s.at(i) == '原创 2014-05-16 14:11:22 · 517 阅读 · 0 评论 -
[LeetCode]Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1",原创 2014-05-16 14:17:34 · 485 阅读 · 0 评论 -
[LeetCode] Valid Number
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo原创 2014-06-24 11:57:41 · 486 阅读 · 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. Could you implement it without using ext原创 2014-08-02 20:49:03 · 331 阅读 · 0 评论 -
[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 like (ie, buy on原创 2014-08-02 21:07:45 · 330 阅读 · 0 评论 -
[LeetCode] 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?其实想想原创 2014-08-02 21:22:51 · 280 阅读 · 0 评论 -
[LeetCode]Sort List
Sort a linked list in O(n log n) time using constant space complexity.zhed原创 2014-05-16 14:40:25 · 378 阅读 · 0 评论 -
[LeetCode] Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.原创 2014-08-02 21:55:20 · 363 阅读 · 0 评论 -
[LeetCode] Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of原创 2014-08-02 21:46:16 · 294 阅读 · 0 评论 -
[LeetCode] Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.原创 2014-08-02 20:55:06 · 450 阅读 · 0 评论 -
[LeetCode] Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.原创 2014-08-02 21:01:29 · 318 阅读 · 0 评论 -
[LeetCode] 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?四个字:快慢指针。原创 2014-08-02 21:18:48 · 381 阅读 · 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 usi原创 2014-08-02 21:26:50 · 307 阅读 · 0 评论 -
[LeetCode] 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 \原创 2014-08-02 21:17:03 · 345 阅读 · 0 评论 -
[LeetCode] Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] ha原创 2014-08-02 21:34:23 · 405 阅读 · 0 评论 -
[LeetCode] Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers原创 2014-08-02 21:52:04 · 291 阅读 · 0 评论 -
[LeetCode] Divide Two Integers
Divide two integers without using multiplication, division and mod operator.原创 2014-08-02 22:21:12 · 417 阅读 · 0 评论 -
[LeetCode] Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before c原创 2014-08-02 21:03:29 · 270 阅读 · 0 评论 -
[LeetCode] Minimum Window Substring !
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN原创 2014-08-02 21:59:14 · 404 阅读 · 0 评论