Isaac Emmanuel
09 Sept 2026•EasyGo / Python / TypeScript

Longest Continuous Increasing Subsequence

Find the length of the longest strictly increasing contiguous segment.

Track the current increasing run and reset it whenever the next value is not greater than its predecessor.

Complexity

O(n) time and O(1) extra space.

Solution files

Go•longest-continuous-increasing-subsequence/solution.go
package main

func findLengthOfLCIS(nums []int) int {
	best, run := 0, 0
	for index, value := range nums {
		if index == 0 || value > nums[index-1] {
			run++
		} else {
			run = 1
		}
		if run > best {
			best = run
		}
	}
	return best
}
Python•longest-continuous-increasing-subsequence/solution.py
class Solution:
    def findLengthOfLCIS(self, nums: list[int]) -> int:
        best = run = 0
        for index, value in enumerate(nums):
            run = run + 1 if index == 0 or value > nums[index - 1] else 1
            best = max(best, run)
        return best
TypeScript•longest-continuous-increasing-subsequence/solution.ts
function findLengthOfLCIS(nums: number[]): number {
  let best = 0;
  let run = 0;
  for (let index = 0; index < nums.length; index += 1) {
    run = index === 0 || nums[index] > nums[index - 1] ? run + 1 : 1;
    best = Math.max(best, run);
  }
  return best;
}