varlengthOfLIS=function(nums){let result =[0];let p = nums.slice();// 缓存每一个result的前置节点let len = nums.length;for(let i =0; i < len; i++){let j = result[result.length -1];let x = nums[j];if(nums[i]> x){
p[i]= j;
result.push(i);}else{// 二分查找 (不懂好好研究一下)let b = result.length;let a =0;while(a < b){
c =(a + b)>>1;if(nums[result[c]]>= nums[i]){
b = c;}else{
a = c +1;}}
p[i]= result[a -1];
result[a]= i;}}// 前驱节点追溯解决序列不对let u = result.length;let v = result[u -1];while(u-->0){
result[u]= v;
v = p[v];// 这就是为什么p存前置节点,为了回溯}return result;};