最长上升子序列问题
Redraiment的走法
http://www.nowcoder.com/questionTerminal/24e6243b9f0446b081b1d6d32f2aa3aa
int lengthOfLIS(vector<int>& nums) { int n = nums.size(); if (n == 0) return 0; vector<int> dp(n, 0); int res = 1; for (int i = 0; i < n; i++) { dp[i] = 1; for (int j = 0; j < i; j++) { if (nums[j] < nums[i]) { dp[i] = max(dp[i], dp[j] + 1); } } res = max(res, dp[i]); } return res; }