- 博客(21)
- 收藏
- 关注
转载 [LeetCode] [First Missing Positive 2012-03-08]
Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant ...
2019-09-28 18:47:45 61
转载 [LeetCode] [Implement strStr() 2012-02-18]
Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. class Solution { public: int GetStringLength(char* p) ...
2019-09-28 18:47:44 67
转载 [LeetCode] [Partition List 2012-04-30]
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each...
2019-09-28 18:47:42 63
转载 [LeetCode] [Jump Game 2012-03-24]
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...
2019-09-28 18:47:41 60
转载 [LeetCode] [Balanced Binary Tree 2012-10-08 ]
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never di...
2019-09-28 18:47:40 71
转载 [LeetCode] [Palindrome Number 2012-01-04]
Determine whether an integer is a palindrome. Do this without extra space. if use recursive, like check the first dig and last dig, then remove them, check the rest, it will fail when digint lik...
2019-09-28 18:47:39 80
转载 [LeetCode] [Binary Tree Preorder Traversal 2013-11-05 ]
Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive soluti...
2019-09-28 18:47:38 48
转载 [LeetCode] [Binary Tree Inorder Traversal 2013-11-05]
Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note: Recursive solutio...
2019-09-28 18:47:37 48
转载 [LeetCode] [Trapping Rain Water 2012-03-10]
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,...
2019-09-28 18:47:37 54
转载 [LeetCode] [Linked List Cycle 2013-10-28 ]
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? /** * Definition for singly-linked list. * struct ListNode { * int ...
2019-09-28 18:47:35 64
转载 [LeetCode] [Add Two Numbers 2011-11-01 ]
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a...
2019-09-28 18:47:35 70
转载 [LeetCode] [Add Binary 2012-04-02 ]
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". string 的操作,短string补位。两个“0”会输出一个“00”,要特殊处理,plus如果最后为“1”,要补上。 class Solution {...
2019-09-28 18:47:34 58
转载 [LeetCode] [Search Insert Position 2012-03-03 ]
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the arr...
2019-09-28 18:47:33 50
转载 [LeetCode] [Reverse Integer 2011-12-25 ]
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 class Solution { public: int reverse(int x) { int s = x; if(x < 0) ...
2019-09-28 18:47:32 60
转载 [LeetCode] [Climbing Stairs 2012-04-03]
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? class Solution { public:...
2019-09-28 18:47:32 49
转载 [LeetCode] [Same Tree 2012-09-03 ]
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. /** ...
2019-09-28 18:47:30 59
转载 [LeetCode] [Single Number 2013-10-01]
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 e...
2019-09-28 18:47:30 62
转载 [LeetCode] [Maximum Depth of Binary Tree 2012-09-29 ]
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. /** * Definition for binar...
2019-09-28 18:47:28 49
转载 [LeetCode] [Single Number II 2013-10-02]
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...
2019-09-28 18:47:28 52
转载 [LeetCode] [Unique Binary Search Trees 2012-08-27]
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 \ ...
2019-09-28 18:47:26 64
转载 [LeetCode] [Unique Paths 2012-03-28]
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 t...
2019-09-28 18:47:24 47
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人