92ms c++


  • 0
    B
    class Solution {
    public:
        int lengthOfLIS(vector<int>& nums) {
            int ans=0;
            int len=nums.size();
            int f[len+5]={0};
            for(int i=0;i<len;i++)
            {
                for(int j=0;j<i;j++)
                    if (nums[i]>nums[j])
                        f[i]=max(f[i],f[j]);
                f[i]++;
                if (f[i]>ans) ans=f[i];
            }
            return ans;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.