intlengthOfLIS(vector<int>& nums){ int len = 1, n = nums.size(); if (len == 0) return0; vector<int> d(nums.size() + 1); d[len] = nums[0]; for (int i = 0; i < n; i++) { if (nums[i] > d[len]) { d[++len] = nums[i]; } else { int l = 1, r = len, m; int pos = 0; while (l <= r) { m = (l + r) / 2; if (d[m] < nums[i]) { pos = m; l = m + 1; } else { r = m - 1; } } d[pos + 1] = nums[i]; } } return len; }