LeetCode
fanguzhai
这个作者很懒,什么都没留下…
展开
-
[勇者闯LeetCode] 257. Binary Tree Paths
[勇者闯LeetCode] 257. Binary Tree PathsDescription Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \2 3 \ 5 All root-to-leaf pa原创 2017-06-24 22:22:53 · 205 阅读 · 0 评论 -
[勇者闯LeetCode] 136. Single Number
[勇者闯LeetCode] 136. Single NumberDescription Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime com原创 2017-05-13 22:40:29 · 330 阅读 · 0 评论 -
[勇者闯LeetCode] 125. Valid Palindrome
[勇者闯LeetCode] 125. Valid PalindromeDescription Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a can原创 2017-05-13 22:33:13 · 205 阅读 · 0 评论 -
[勇者闯LeetCode] 110. Balanced Binary Tree
[勇者闯LeetCode] 110. Balanced Binary TreeDescription 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 t原创 2017-04-22 14:32:34 · 248 阅读 · 0 评论 -
[勇者闯LeetCode] 108. Convert Sorted Array to Binary Search Tree
[勇者闯LeetCode] 108. Convert Sorted Array to Binary Search TreeDescription Given an array where elements are sorted in ascending order, convert it to a height balanced BST.InformationTags: Tree | Dep原创 2017-04-22 14:13:01 · 209 阅读 · 0 评论 -
[勇者闯LeetCode] 1. Two Sum
[勇者闯LeetCode] 1. Two SumDescription Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one原创 2017-03-05 21:46:32 · 189 阅读 · 0 评论 -
[勇者闯LeetCode] 107. Binary Tree Level Order Traversal II
[勇者闯LeetCode] 107. Binary Tree Level Order Traversal IIDescription Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from l原创 2017-04-15 09:24:13 · 177 阅读 · 0 评论 -
[勇者闯LeetCode] 118. Pascal's Triangle
[勇者闯LeetCode] 118. Pascal’s TriangleDescription Given numRows, generate the first numRows of Pascal’s triangle. For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,原创 2017-04-29 21:11:03 · 199 阅读 · 0 评论 -
[勇者闯LeetCode] 112. Path Sum
[勇者闯LeetCode] 112. Path SumDescription 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 ex原创 2017-04-29 20:48:08 · 292 阅读 · 0 评论 -
[勇者闯LeetCode] 111. Minimum Depth of Binary Tree
[勇者闯LeetCode] 111. Minimum Depth of Binary TreeDescription Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down t原创 2017-04-29 20:35:12 · 236 阅读 · 0 评论 -
[勇者闯LeetCode] 121. Best Time to Buy and Sell Stock
[勇者闯LeetCode] 121. Best Time to Buy and Sell StockDescription Say you have an array for which the ithi^{th} element is the price of a given stock on day ii. If you were only permitted to complet原创 2017-05-06 23:19:37 · 198 阅读 · 0 评论 -
[勇者闯LeetCode] 155. Min Stack
[勇者闯LeetCode] 155. Min StackeDescription Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Remov原创 2017-05-27 19:56:27 · 215 阅读 · 0 评论 -
[勇者闯LeetCode] 129. Sum Root to Leaf Number
[勇者闯LeetCode] 129. Sum Root to Leaf NumberDescription Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1-原创 2017-07-03 22:59:03 · 205 阅读 · 0 评论 -
[勇者闯LeetCode] 169. Majority Element
[勇者闯LeetCode] 169. Majority ElementDescription Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that原创 2017-06-03 23:09:16 · 349 阅读 · 0 评论 -
[勇者闯LeetCode] 167. Two Sum II - Input array is sorted
[勇者闯LeetCode] 167. Two Sum II - Input array is sortedDescription Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target numb原创 2017-06-03 22:27:21 · 226 阅读 · 0 评论 -
[勇者闯LeetCode] 191. Number of 1 Bits
[勇者闯LeetCode] 191. Number of 1 BitsDescription Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight). For example, the 32-b原创 2017-06-17 21:16:54 · 226 阅读 · 0 评论 -
[勇者闯LeetCode] 190. Reverse Bits
[勇者闯LeetCode] 169. Majority ElementDescription Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return原创 2017-06-10 10:09:54 · 246 阅读 · 0 评论 -
[勇者闯LeetCode] 189. Rotate Array
[勇者闯LeetCode] 189. Rotate ArrayDescription Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Info原创 2017-06-10 09:55:35 · 199 阅读 · 0 评论 -
[勇者闯LeetCode] 142. Linked List Cycle II
[勇者闯LeetCode] 142. Linked List Cycle IIDescription Given a linked list, return the node where the cycle begins. If there is no cycle, return null.InformationTags: Linked List | Two PointersDifficu原创 2017-05-19 23:16:38 · 234 阅读 · 0 评论 -
[勇者闯LeetCode] 141. Linked List Cycle
[勇者闯LeetCode] 141. Linked List CycleDescription Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space?InformationTags: Linked List |原创 2017-05-19 22:48:39 · 200 阅读 · 0 评论 -
[勇者闯LeetCode] 160. Intersection of Two Linked Lists
[勇者闯LeetCode] 160. Intersection of Two Linked ListsDescription Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked l原创 2017-05-27 20:32:22 · 200 阅读 · 0 评论 -
[勇者闯LeetCode] 70. Climbing Stairs
[勇者闯LeetCode] 70. Climbing StairsDescription 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 c原创 2017-03-26 15:36:21 · 402 阅读 · 0 评论 -
[勇者闯LeetCode] 66. Plus One
[勇者闯LeetCode] 66. Plus OneDescription Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leading zero原创 2017-03-26 15:19:21 · 183 阅读 · 0 评论 -
[勇者闯LeetCode] 101. Symmetric Tree
[勇者闯LeetCode] 101. Symmetric TreeDescription Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symme原创 2017-04-02 10:31:33 · 234 阅读 · 0 评论 -
[勇者闯LeetCode] 7. Reverse Integer
[勇者闯LeetCode] 7. Reverse IntegerDescription Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Here are some good questions to ask before coding. B原创 2017-03-05 22:06:49 · 347 阅读 · 0 评论 -
[勇者闯LeetCode] 11. Container With Most Water
[勇者闯LeetCode] 11. Container With Most WaterDescription Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two e原创 2017-03-19 11:10:20 · 278 阅读 · 0 评论 -
[勇者闯LeetCode] 6. ZigZag Conversion
[勇者闯LeetCode] 6. ZigZag ConversionDescription The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for原创 2017-03-19 10:35:51 · 220 阅读 · 0 评论 -
[勇者闯LeetCode] 38. Count and Say
[勇者闯LeetCode] 38. Count and SayDescription The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is r原创 2017-03-19 09:55:06 · 214 阅读 · 0 评论 -
[勇者闯LeetCode] 35. Search Insert Position
[勇者闯LeetCode] 35. Search Insert PositionDescription 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原创 2017-03-19 09:50:03 · 163 阅读 · 0 评论 -
[勇者闯LeetCode] 28. Implement strStr()
[勇者闯LeetCode] 28. Implement strStr()Description Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.InformationTags: Two原创 2017-03-19 09:41:01 · 343 阅读 · 0 评论 -
[勇者闯LeetCode] 9. Palindrome Number
[勇者闯LeetCode] 9. Palindrome NumberDescription Determine whether an integer is a palindrome. Do this without extra space.InformationTags: MathDifficulty: EasySolutionclass Solution(object): de原创 2017-03-05 22:10:03 · 425 阅读 · 0 评论 -
[勇者闯LeetCode] 215. Kth Largest Element in an Array
[勇者闯LeetCode] 215. Kth Largest Element in an ArrayDescription Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct elem原创 2017-03-05 21:07:02 · 185 阅读 · 0 评论 -
[勇者闯LeetCode] 69. Sqrt(x)
[勇者闯LeetCode] 69. Sqrt(x)Description Implement int sqrt(int x). Compute and return the square root o xInformationTags: Binary Search | MatchDifficulty: EasyTips: 二分搜索 O(logN)Solutionclass Sol原创 2017-03-05 21:03:25 · 434 阅读 · 0 评论 -
[勇者闯LeetCode] 13. Roman to Integer
[勇者闯LeetCode] 13. Roman to IntegerDescriptionGiven a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.InformationTags: Math | StringDifficulty: Easy原创 2017-03-05 22:13:38 · 205 阅读 · 0 评论 -
[勇者闯LeetCode] 14. Longest Common Prefix
[勇者闯LeetCode] 14. Longest Common PrefixDescription Write a function to find the longest common prefix string amongst an array of strings.InformationTags: StringDifficulty: EasySolution列向扫描字符是否相同,原创 2017-03-10 23:28:44 · 225 阅读 · 0 评论 -
[勇者闯LeetCode] 88. Merge Sorted Array
[勇者闯LeetCode] 88. Merge Sorted ArrayDescription Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (原创 2017-04-02 10:20:04 · 332 阅读 · 0 评论 -
[勇者闯LeetCode] 83. Remove Duplicates from Sorted List
[勇者闯LeetCode] 83. Remove Duplicates from Sorted ListDescription Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1原创 2017-04-02 10:13:18 · 325 阅读 · 0 评论 -
[勇者闯LeetCode] 58. Length of Last Word
[勇者闯LeetCode] 58. Length of Last WordDescription Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string. If the last原创 2017-03-25 11:50:46 · 200 阅读 · 0 评论 -
[勇者闯LeetCode] 53. Maximum Subarray
[勇者闯LeetCode] 53. Maximum SubarrayDescription 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,原创 2017-03-25 11:47:10 · 326 阅读 · 0 评论 -
[勇者闯LeetCode] 104. Maximum Depth of Binary Tree
[勇者闯LeetCode] 104. Maximum Depth of Binary TreeDescription 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原创 2017-04-09 15:51:48 · 171 阅读 · 0 评论