problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::longest_increasing_subsequence::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int lengthOfLIS (vector< int > &nums)
 

详细描述

在文件 leetcode.h2491 行定义.

成员函数说明

◆ lengthOfLIS()

int leetcode::longest_increasing_subsequence::Solution::lengthOfLIS ( vector< int > &  nums)
static

在文件 leetcode.cpp6716 行定义.

6716 {
6717 const int n = nums.size();
6718 int ans = 1;
6719 vector dp(n, 1);//length of longest increasing subsequence end with i
6720 for(int i = 0; i < n; i++) {
6721 for(int j = i + 1; j < n; j++) {
6722 if(nums[j] > nums[i]) {
6723 dp[j] = max(dp[j], dp[i] + 1);
6724 }
6725 }
6726 ans = max(ans, dp[i]);
6727 }
6728 return ans;
6729 }

被这些函数引用 leetcode::longest_increasing_subsequence::TEST().


该类的文档由以下文件生成: