Leetcode题解
记录写题中遇到的解题思路和方法
茵茵的聪聪
这个作者很懒,什么都没留下…
展开
-
42. Trapping Rain Water && Binary Tree Preorder\Postorder\Inorder Traversal
42. Trapping Rain Water 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. The above elevation m...原创 2018-08-24 16:13:11 · 123 阅读 · 0 评论 -
401. Binary Watch && 51. N-Queens
401. Binary Watch(回溯法基本应用) A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with t...原创 2018-08-23 16:34:04 · 115 阅读 · 0 评论 -
218. The Skyline Problem && 241. Different Ways to Add Parentheses
218. The Skyline Problem A city’s skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and heig...原创 2018-08-22 21:42:26 · 295 阅读 · 0 评论 -
4. Median of Two Sorted Arrays && 23. Merge k Sorted Lists
4. Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+...原创 2018-08-22 11:11:40 · 105 阅读 · 0 评论 -
222. Count Complete Tree Nodes && 710. Random Pick with Blacklist
222. Count Complete Tree Nodes Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except pos...原创 2018-08-15 18:39:06 · 169 阅读 · 0 评论 -
53. Maximum Subarray && 229. Majority Element II
53. Maximum Subarray Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5...原创 2018-07-20 15:57:58 · 139 阅读 · 0 评论 -
212. Word Search II && 215. Kth Largest Element in an Array
212. Word Search II Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where “adjacent” ...原创 2018-07-23 23:38:44 · 162 阅读 · 0 评论