Skip to main content

Command Palette

Search for a command to run...

Longest Continuous Increasing Subsequence

Published
1 min read
Longest Continuous Increasing Subsequence
G

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.

I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.

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].

LeetCode Problem - 674

class Solution {
    public int findLengthOfLCIS(int[] nums) {

        // Initialize the answer with 1 since the smallest possible LCIS has length 1
        int answer = 1;

        // Variable to track the current length of the increasing subsequence
        int currentLength = 1;

        // Iterate through the array, starting from the first element to the second last element
        for(int i = 0; i < nums.length - 1; i++) {

            // Check if the next element is greater than the current element
            if(nums[i + 1] > nums[i]) {
                // If true, increment the length of the current increasing subsequence
                currentLength++;
            } else {
                // If false, reset the length of the current increasing subsequence to 1
                currentLength = 1;
            }

            // Update the answer with the maximum length found so far
            answer = Math.max(answer, currentLength);
        }

        // Return the length of the longest continuous increasing subsequence
        return answer;
    }
}

More from this blog

S

Software and Performance Testing Insights

462 posts

Results-Driven Agile QA Specialist | Expert in Mobile & Web Testing | Proficient in Test Planning, Execution, and Root Cause Analysis.