674. Longest Continuous Increasing Subsequence LeetCode Solution
In this guide, you will get 674. Longest Continuous Increasing Subsequence LeetCode Solution with the best time and space complexity. The solution to Longest Continuous Increasing Subsequence problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- Longest Continuous Increasing Subsequence solution in C++
- Longest Continuous Increasing Subsequence solution in Java
- Longest Continuous Increasing Subsequence solution in Python
- Additional Resources

Problem Statement of Longest Continuous Increasing Subsequence
Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e. subarray). The subsequence must be strictly increasing.
A continuous increasing subsequence is defined by two indices l and r (l < r) such that it is [nums[l], nums[l + 1], …, nums[r – 1], nums[r]] and for each l <= i < r, nums[i] < nums[i + 1].
Example 1:
Input: nums = [1,3,5,4,7]
Output: 3
Explanation: The longest continuous increasing subsequence is [1,3,5] with length 3.
Even though [1,3,5,7] is an increasing subsequence, it is not continuous as elements 5 and 7 are separated by element
4.
Example 2:
Input: nums = [2,2,2,2,2]
Output: 1
Explanation: The longest continuous increasing subsequence is [2] with length 1. Note that it must be strictly
increasing.
Constraints:
1 <= nums.length <= 104
-109 <= nums[i] <= 109
Complexity Analysis
- Time Complexity: O(n)
- Space Complexity: O(1)
674. Longest Continuous Increasing Subsequence LeetCode Solution in C++
class Solution {
public:
int findLengthOfLCIS(vector<int>& nums) {
int ans = 0;
for (int l = 0, r = 0; r < nums.size(); ++r) {
if (r > 0 && nums[r] <= nums[r - 1])
l = r;
ans = max(ans, r - l + 1);
}
return ans;
}
};
/* code provided by PROGIEZ */
674. Longest Continuous Increasing Subsequence LeetCode Solution in Java
class Solution {
public int findLengthOfLCIS(int[] nums) {
int ans = 0;
for (int l = 0, r = 0; r < nums.length; ++r) {
if (r > 0 && nums[r] <= nums[r - 1])
l = r;
ans = Math.max(ans, r - l + 1);
}
return ans;
}
}
// code provided by PROGIEZ
674. Longest Continuous Increasing Subsequence LeetCode Solution in Python
class Solution:
def findLengthOfLCIS(self, nums: list[int]) -> int:
ans = 0
j = 0
for i in range(len(nums)):
if i > 0 and nums[i] <= nums[i - 1]:
j = i
ans = max(ans, i - j + 1)
return ans
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.