- 博客(14)
- 收藏
- 关注
原创 LeetCode 525 Contiguous Array (hash)
Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.Example 1:Input: [0,1]Output: 2Explanation: [0, 1] is the longest contiguous subarray with eq...
2019-02-28 08:47:08 116
原创 LeetCode 813 Largest Sum of Averages (dp)
We partition a row of numbersAinto at mostKadjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve?Note that our partition m...
2019-02-27 23:46:09 186
原创 LeetCode 983 Minimum Cost For Tickets (dp)
In a country popular for train travel, youhave planned some train travelling one year in advance. The days of the year that you will travel is given as an arraydays. Each day is an integer from1...
2019-02-27 13:52:51 143
原创 LeetCode 845 Longest Mountain in Array (模拟)
Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold:B.length >= 3 There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] <...
2019-02-26 22:40:45 241
原创 LeetCode 210 Course Schedule II (拓扑排序)
There are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair...
2019-02-26 22:11:52 312
原创 LeetCode 816 Ambiguous Coordinates (DFS)
We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)". Then, we removed all commas, decimal points, and spaces, and ended up with the string S. Return a list of strings representing all...
2019-02-26 21:20:37 356
原创 LeetCode 445 Add Two Numbers II (链表)
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return i...
2019-02-25 19:35:43 200
原创 LeetCode 696 Count Binary Substrings (模拟)
Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively.Substri...
2019-02-21 21:48:36 261
原创 LeetCode 376 Wiggle Subsequence (模拟)
A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either pos...
2019-02-21 21:01:51 181
原创 LeetCode 324. Wiggle Sort II (二分+三分 推荐)
Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....Example 1:Input: nums = [1, 5, 1, 1, 6, 4]Output: One possible answer is [1, 4, 1, 5, 1, 6]...
2019-02-21 02:01:48 550
原创 LeetCode 146 LRU Cache (双向链表 map)
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be positive) of the key if th...
2019-02-14 23:30:33 373
原创 LeetCode 543 Diameter of Binary Tree (DFS 树的直径)
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may n...
2019-02-13 09:35:19 321
原创 LeetCode 216 Combination Sum III (DFS)
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Note:All numbers will ...
2019-02-12 22:00:49 151
原创 LeetCode 862 Shortest Subarray with Sum at Least K (单调队列 推荐)
Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K.If there is no non-empty subarray with sum at least K, return -1.Example 1:Input: A = [1], K = 1Outpu...
2019-02-12 14:40:52 1281
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人