
dynamic planning
老晨磕技术
每天定时定量,持之以恒。一天一点数十年持续积累,坚持的人总不会混得太差。
展开
-
晨哥Leetcode 689. Maximum Sum of 3 Non-Overlapping Subarrays
In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum.Each subarray will be of size k, and we want to maximize the sum of all 3*k entries.Return the resu...原创 2019-09-01 10:39:49 · 194 阅读 · 0 评论 -
晨哥Leetcode 727. Minimum Window Subsequence 最小窗口子序列
Given strings S and T, find the minimum (contiguous) substring W of S, so that T is a subsequence of W.If there is no such window in S that covers all characters in T, return the empty string “”. If...原创 2019-09-08 23:43:27 · 1258 阅读 · 0 评论 -
晨哥Leetcode 873 最长斐波那契序列的长度 · Length of Longest Fibonacci Subsequence
A sequence X_1, X_2, …, X_n is fibonacci-like if:n >= 3X_i + X_{i+1} = X_{i+2} for all i + 2 <= nGiven a strictly increasing array A of positive integers forming a sequence, find the length ...原创 2019-09-15 06:09:42 · 119 阅读 · 0 评论 -
老晨Leetcode 376. Wiggle Subsequence 摆动序列
如果连续数字之间的差严格地在正和负之间交替,则这样的数字序列称为摆动序列。 第一个差值(如果存在)可以是正的也可以是负的。 少于两个元素的序列通常是摆动序列。例如,[1,7,4,9,2,5]是一个摆动序列,因为连续数字的差(6,-3,5,-7,3)交替为正和负。 相反,[1,4,7,2,5]和[1,7,4,5,5]不是摆动序列,第一个是因为它的前两个连续数字的差是正的,而第二个是因为它的最后一...原创 2019-09-16 10:28:02 · 125 阅读 · 0 评论 -
老晨Leetcode 673 最长升序子序列的个数 · Number of Longest Increasing Subsequence
给定一个无序的整数序列,找到最长的升序子序列的个数。Example 1:Input: [1,3,5,4,7]Output: 2Explanation: The two longest increasing subsequence are [1, 3, 4, 7] and [1, 3, 5, 7].这道题很明显是用动态规划做,当你处理到nums[i]这个数的时候,只需要保留以这个数结尾...原创 2019-09-22 23:30:38 · 213 阅读 · 0 评论 -
老晨Leetcode 1027. Longest Arithmetic Sequence (Java)
Given an array A of integers, return the length of the longest arithmetic subsequence in A.Recall that a subsequence of A is a list A[i_1], A[i_2], …, A[i_k] with 0 <= i_1 < i_2 < … < i_...原创 2019-10-02 12:15:39 · 275 阅读 · 0 评论