题目描述
题目分析
一遍遍历,如果硬要说用了什么算法的话觉得应该算是一个简单的滑动窗口吧
AC代码
class Solution {
public:int findLengthOfLCIS(vector<int>& nums) {if (nums.size() == 0) {return 0;}int ret = 1;int cnt = 1;for (int i = 1; i < nums.size(); ++i) {if (nums[i] > nums[i-1]) {++cnt;} else {if (cnt > ret) {ret = cnt;}cnt = 1;}}if (cnt > ret) {ret = cnt;}return ret;}
};