这是悦乐书的第 270 次更新,第 284 篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第136题(顺位题号是594)。我们定义一个和谐数组是一个数组,其最大值和最小值之间的差值恰好为1。给定一个整数数组,在其所有可能的子序列中找到其最长的和谐子序列的长度。例如: 输 ...
分类:
编程语言 时间:
2019-03-08 09:15:25
阅读次数:
190
使用vector 在解决一些问题的时候确实非常高效。 可以不像Array 那样一个一个去查。 可以大幅度缩减代码实现的时间。 Given a string, find the length of the longest substring without repeating characters. ...
分类:
编程语言 时间:
2019-03-06 09:21:25
阅读次数:
280
题目如下: Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The a ...
分类:
其他好文 时间:
2019-03-06 09:20:37
阅读次数:
161
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l ...
分类:
其他好文 时间:
2019-03-05 11:15:23
阅读次数:
140
Given an array A of 0s and 1s, we may change up to K values from 0 to 1. Return the length of the longest (contiguous) subarray that contains only 1s. ...
分类:
其他好文 时间:
2019-03-04 09:50:29
阅读次数:
92
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l ...
分类:
其他好文 时间:
2019-03-04 09:31:18
阅读次数:
160
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 t ...
分类:
编程语言 时间:
2019-03-02 01:08:18
阅读次数:
221
一、数组 8) 双指针 滑动窗口 例题: 3. Longest Substring Without Repeating Characters 描述:Given a string, find the length of the longest substring without repeating c ...
分类:
其他好文 时间:
2019-02-24 19:04:19
阅读次数:
137
LCS--Longest Common Subsequence,即最长公共子序列,一般使用DP来解。 常规方法: dp[i][j]表示字符串s1前i个字符组成的字符串与s2前j个字符组成的字符串的LCS的长度,则当s1[i-1]==s2[j-1]时,dp[i][j]=dp[i-1][j-1],否则d ...
分类:
其他好文 时间:
2019-02-24 01:01:14
阅读次数:
194
QueryString = { data: {}, Initial: function() { var aPairs, aTmp; var queryString = new String(window.location.search); queryString = queryString.subs ...
分类:
Web程序 时间:
2019-02-22 23:02:22
阅读次数:
395