leetcode 300 最长上升子序列

这个题目一开始没看清楚

输入: [10,9,2,5,3,7,101,18]

输出: 4

解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。

我理解成了最长上升连续子序列 这样的话答案应该是3而不是实例种的4 虽然写错了 但还是把我使用单调栈方式写的最长连续子序列的代码贴出来

class Solution {
public:
    int lengthOfLIS(vector& nums) {
        int n = nums.size();
        stack in;
        int ans=0,Ans=0;
        in.push(nums[0]);
        for(int i = 1;i

你可能感兴趣的:(leetcode 300 最长上升子序列)