- 博客(169)
- 收藏
- 关注
原创 [LeetCode] HashMap题目总结
1. Two Sum找出数组中加起来等于target的两个数。每一个输入有且仅有一个解,但是同一个元素不能使用两次。可以使用HashMap + 单遍循环,key为数组中的元素,value为下标。如果hashmap中已经存储过target - nums[i]了,那么就找到了一对结果。如果没有存储过target - nums[i],那么就将(nums[i] , i)放入HashMap。class...
2019-12-15 16:50:02
846
原创 [LeetCode] 118. Pascal's Triangle
原题链接:https://leetcode.com/problems/pascals-triangle/1. 题目介绍Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the...
2019-12-01 00:05:56
229
原创 [LeetCode] 273. Integer to English Words
原题链接:https://leetcode.com/problems/integer-to-english-words/1. DescriptionConvert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.Examp...
2019-09-27 11:35:34
251
原创 [LeetCode] 349. Intersection of Two Arrays
原题链接:https://leetcode.com/problems/intersection-of-two-arrays/1. DescriptionGiven two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2]Outpu...
2019-09-26 23:56:49
202
原创 [LeetCode] 543. Diameter of Binary Tree
原题链接:https://leetcode.com/problems/diameter-of-binary-tree/1. DescriptionGiven a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length ...
2019-09-26 23:53:07
198
原创 [LeetCode] 415. Add Strings
原题链接:https://leetcode.com/problems/add-strings/1. DescriptionGiven two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and n...
2019-09-26 23:43:30
196
原创 [LeetCode] 9. Palindrome Number
原题链接:https://leetcode.com/problems/palindrome-number/1. DescriptionDetermine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Inp...
2019-09-24 12:03:14
155
原创 [LeetCode] 253. Meeting Rooms II
原题链接:https://leetcode.com/problems/meeting-rooms-ii/1. DescriptionGiven an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],…] (si < ei), find the minimum number...
2019-09-24 11:16:02
199
原创 [LeetCode] 56. Merge Intervals
原题链接:https://leetcode.com/problems/merge-intervals/1. DescriptionGiven a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10...
2019-09-23 07:56:35
188
原创 [LeetCode] 252. Meeting Rooms
原题链接:https://leetcode.com/problems/meeting-rooms/1. DescriptionGiven an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],…] (si < ei), determine if a person coul...
2019-09-23 06:32:02
275
原创 [LeetCode] 953. Verifying an Alien Dictionary
原题链接:https://leetcode.com/problems/verifying-an-alien-dictionary/1. DescriptionIn an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The orde...
2019-09-23 04:28:33
188
原创 [LeetCode] 1021. Remove Outermost Parentheses
原题链接:https://leetcode.com/problems/remove-outermost-parentheses/1. DescriptionA valid parentheses string is either empty (""), “(” + A + “)”, or A + B, where A and B are valid parentheses strings, a...
2019-09-23 04:01:33
211
原创 [LeetCode] 75. Sort Colors (Quick Sort)
1. DescriptionGiven an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we w...
2019-09-12 05:15:08
224
原创 [LeetCode] 454. 4Sum II
原题链接: https://leetcode.com/problems/4sum-ii/1. 题目介绍Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make ...
2019-07-31 18:41:07
164
原创 [LeetCode] 80. Remove Duplicates from Sorted Array II
原题链接:https://leetcode.com/problems/remove-element/1. 题目介绍Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for a...
2019-07-25 23:05:55
169
原创 [LeetCode] 283. Move Zeroes
原题链接:https://leetcode.com/problems/move-zeroes/1. 题目介绍Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.给出一个数组nums...
2019-07-24 22:04:24
157
原创 [LeetCode] 42. Trapping Rain Water
1. 题目介绍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.给出n个非负整数组成的数组,代表了一个柱状图中各柱子的高度。每一个柱子的宽度都是1...
2019-07-21 22:16:34
180
原创 [LeetCode] 108. Convert Sorted Array to Binary Search Tree
原题链接:1. 题目介绍2. 解题思路
2019-06-30 09:48:05
161
原创 [LeetCode] 106. Construct Binary Tree from Inorder and Postorder Traversal
原题链接:1. 题目介绍2. 解题思路
2019-06-28 17:35:23
157
原创 [LeetCode] 105. Construct Binary Tree from Preorder and Inorder Traversal
原题链接:
2019-06-28 16:11:16
184
原创 [LeetCode] 988. Smallest String Starting From Leaf
原题链接:https://leetcode.com/problems/smallest-string-starting-from-leaf/
2019-06-25 23:46:44
281
原创 [LeetCode] 865. Smallest Subtree with all the Deepest Nodes
原题链接:https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/1. 题目介绍Given a binary tree rooted at root, the depth of each node is the shortest distance to the root.A node is deepe...
2019-06-17 02:01:54
245
原创 [LeetCode] 101. Symmetric Tree
原题链接:https://leetcode.com/problems/symmetric-tree/1. 题目介绍Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).给定一个二叉树,检查是否是中心对称的。For example, this binary t...
2019-06-15 12:52:04
167
原创 [LeetCode] 987. Vertical Order Traversal of a Binary Tree
原题链接:https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/1. 题目介绍Given a binary tree, return the vertical order traversal of its nodes values.For each node at position (X, Y), it...
2019-06-15 02:55:40
269
原创 [LeetCode] 897. Increasing Order Search Tree
原题链接: https://leetcode.com/problems/increasing-order-search-tree/
2019-06-11 16:46:31
273
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人