Simple Java ☕ Solution using 2 pointer approach | Time: Beats 100% of the Solutions ✅
Intuition\n Describe your first thoughts on how to solve this problem. \nWe are to find the longest continuous increasing subsequence(LCIS), for that, what I th
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe are to find the longest continuous increasing subsequence(LCIS), for that, what I thought was that, if we are checking the length from an element at any index, and if we reach a point that now our subsequence is not increasing, then we need not to check the length of longest cont. inc. subsequence.\n\nFor eg:\n[1,3,5,4,***2,3,4,5***]\n\nhere 2,3,4,5 is our LCIS, what I mean to say in above paragraph was, when we check the LCIS from element at index 0, it ends at element at index 2, now we need not to look for LCIS from element at index 1 and 2, as there length will always be lesser than that of element at index 0.\n\nI checked the length of each such part of array and returned the maximum one.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe will use 2 pointers to solve this problem, we will keep the track of previous element and j will keep track of current element. \n\nWe will compare nums[i] and nums[j] if nums[j]>nums[i], then currentCount(variable to store the length of current LCIS) will be incremented. \n\nIf nums[j]>nums[i] is false, means this was the end of current LCIS and we now need to check the next LCIS means, we will now chance i to j, increament j and make currentCount to 1.\n\nIn every iteration we are also updating maxCount if currentCount gets greater than it. \n\nAt last we are returning the maxCount.\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution \n{\n    public int findLengthOfLCIS(int[] nums) \n    {\n        int maxCount = 1;\n        int currentCount = 1;\n        int i = 0 ;\n        int j = 1;\n        while(j<nums.length)\n        {\n            if(nums[j]>nums[i])\n            {\n                currentCount++;\n                i++;\n                j++;\n            }\n            else\n            {\n                i = j;\n                j++;\n                currentCount = 1;\n            }\n            if(maxCount<currentCount)\n            {\n                maxCount = currentCount;\n            }\n            \n        }  \n        return maxCount;  \n    }\n}\n```\n\n\n****Do Upvote if found useful.**** \u2B06\uFE0F
['Two Pointers', 'Java']