Skip to content

Commit cd22dac

Browse files
committed
feat: add question 674
1 parent 0abd2c1 commit cd22dac

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

674.data

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[1,3,5,4,7]
2+
[1,3,5,4,2,3,4,5]

674.最长连续递增序列.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* @lc app=leetcode.cn id=674 lang=javascript
3+
*
4+
* [674] 最长连续递增序列
5+
*/
6+
7+
// @lc code=start
8+
/**
9+
* @param {number[]} nums
10+
* @return {number}
11+
*/
12+
var findLengthOfLCIS = function(nums) {
13+
if (nums.length === 0) {
14+
return 0;
15+
} else if (nums.length === 1) {
16+
return 1;
17+
}
18+
19+
let result = 0;
20+
let current = 1;
21+
for (let i = 1; i < nums.length; i++) {
22+
if (nums[i] > nums[i - 1]) {
23+
current++;
24+
} else {
25+
current = 1;
26+
}
27+
result = Math.max(result, current);
28+
}
29+
30+
return result;
31+
};
32+
// @lc code=end
33+

0 commit comments

Comments
 (0)