LeetCode真题
cai_yt_
这个作者很懒,什么都没留下…
展开
-
Algorithms(三)Evaluate Division
题目:Evaluate DivisionEquations are given in the format A / B = k, where A andB are variables represented as strings, and k is a real number (floating point number). Given some queries, retu原创 2017-09-24 14:24:23 · 223 阅读 · 0 评论 -
Algorithms(十六)Permutations II
题目:47. Permutations IIGiven a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[原创 2018-01-13 15:58:41 · 202 阅读 · 0 评论 -
Algorithms(九)Jump Game II
题目:45. Jump Game IIGiven 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 th原创 2018-01-12 02:12:24 · 115 阅读 · 0 评论 -
Algorithms(十二)Best Time to Buy and Sell Stock III
题目:123. Best Time to Buy and Sell Stock IIISay you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may com原创 2018-01-12 21:35:56 · 153 阅读 · 0 评论 -
Algorithms(八)Jump Game
题目:55. Jump GameGiven 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原创 2018-01-12 01:58:38 · 153 阅读 · 0 评论 -
Algorithms(六)Best Time to Buy and Sell Stock II
题目:122. Best Time to Buy and Sell Stock IISay you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may comp原创 2017-12-29 00:17:57 · 146 阅读 · 0 评论 -
Algorithms(十五)Permutations
题目:46. PermutationsGiven a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,原创 2018-01-13 14:47:22 · 154 阅读 · 0 评论 -
Algorithms(十四)Pow(x, n)
题目:50. Pow(x, n)Implement pow(x, n).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100代码:class Solution {public: double myPow(d原创 2018-01-13 01:29:52 · 214 阅读 · 0 评论 -
Algorithms(十三)Kth Smallest Element in a BST
题目:230. Kth Smallest Element in a BSTGiven a binary search tree, write a function kthSmallest to find thekth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST'原创 2018-01-12 21:47:21 · 172 阅读 · 0 评论 -
Algorithms(十一)Unique Paths II
题目:63. Unique Paths IIFollow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1原创 2018-01-12 19:41:43 · 152 阅读 · 0 评论 -
Algorithms(十)Unique Paths
题目:62. Unique PathsA 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 ro原创 2018-01-12 15:48:25 · 139 阅读 · 0 评论 -
Algorithms(五)Best Time to Buy and Sell Stock
题目:121. Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transactio原创 2017-12-27 21:51:00 · 153 阅读 · 0 评论 -
Algorithms(四)Employee Importance
题目:Employee ImportanceYou are given a data structure of employee information, which includes the employee'sunique id, his importance value and his direct subordinates' id. For example, e原创 2017-10-01 17:30:08 · 150 阅读 · 0 评论 -
Algorithms(一)Two Sum
题目:Two SumGiven 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 solution, and you may n原创 2017-09-10 17:58:10 · 283 阅读 · 0 评论 -
Algorithms(二)Maximum Subarray
题目:Maximum SubarrayFind 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 contig原创 2017-09-17 14:35:15 · 184 阅读 · 0 评论 -
Algorithms(七)Single Number
题目:136. Single NumberGiven 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原创 2018-01-05 15:39:33 · 167 阅读 · 0 评论