标签:一个 sequence second incr cond 实现 ++ 个数 ted
674. 最长连续递增序列
674. Longest Continuous Increasing Subsequence
题目描述
给定一个未经排序的整型数组,找到最长且连续的递增序列。
Given an unsorted array of integers, find the length of longest continuous increasing
subsequence (subarray).
每日一算法2019/5/21Day 18LeetCode674. Longest Continuous Increasing Subsequence
示例 1:
示例 2:
注意: 数组长度不会超过 10000。
Java 实现
class Solution {
public int findLengthOfLCIS(int[] nums) {
int res = 0, cnt = 0;
for (int i = 0; i < nums.length; i++) {
if (i == 0 || nums[i - 1] < nums[i]) {
res = Math.max(res, ++cnt);
} else {
cnt = 1;
}
}
return res;
}
}
相似题目
参考资料
LeetCode 674. 最长连续递增序列(Longest Continuous Increasing Subsequence) 18
标签:一个 sequence second incr cond 实现 ++ 个数 ted
原文地址:https://www.cnblogs.com/hglibin/p/10899083.html