We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
从一个整数数组中,找出位置连续的最长递增序列。 这道题类似于674. 最长连续递增序列,只不过这道题是找最长递增序列的个数,但是解法差不多。
function findList(nums){ if(nums.length<=1) return nums; let temp = [], res = []; for(let i=1; i<nums.length; i++){ if(nums[i]>nums[i-1]){ temp.push(nums[i]); }else{ if(res.length<temp.length){ res = []; res.push(...temp); } temp=[]; } } return res.length<temp.length ? temp : res; }
The text was updated successfully, but these errors were encountered:
请问循环从i=1开始的话,i=0如何被处理? 比如[1,3,5,4,7],这里的1就会被遗忘,结果等于[3,5]是错误的
Sorry, something went wrong.
No branches or pull requests
从一个整数数组中,找出位置连续的最长递增序列。
这道题类似于674. 最长连续递增序列,只不过这道题是找最长递增序列的个数,但是解法差不多。
The text was updated successfully, but these errors were encountered: