Longest Continuous Increasing Subsequence

2017/11/30

Given an unsorted array of integers, find the length of longest continuous increasing subsequence.

class Solution {
public:
    int findLengthOfLCIS(vector<int>& nums) {
        int tmp = 1;
        int result = 1;
        if (nums.size()==1) {
            return tmp;
        }
        if (nums.empty()) {
            return 0;
        }
        nums.push_back(INT_MIN);
        for (int i =1; i<nums.size(); i++) {
            if (nums[i]>nums[i-1]) {
                tmp++;
            }else{
                result = max(tmp, result);
                tmp = 1;
            }
        }
        return result; 
    }
};