huang色网站,成都网站建设优化公司电话,如何用html在公司的网站上添加栏目路径,优化是企业通过网站来做吗目录 1.最长递增三元子序列
2.最长连续递增序列 1.最长递增三元子序列
题目链接#xff1a;. - 力扣#xff08;LeetCode#xff09; 思路#xff1a;我们只需要设置两个数进行比较就好。设a为nums[0]#xff0c;b 为一个无穷大的数#xff0c;只要有比a小的数字就赋值…目录 1.最长递增三元子序列
2.最长连续递增序列 1.最长递增三元子序列
题目链接. - 力扣LeetCode 思路我们只需要设置两个数进行比较就好。设a为nums[0]b 为一个无穷大的数只要有比a小的数字就赋值a比a大的数字就赋值b如果有比b大的数字说明可以组成一个三元子序列直接返回true
代码如下
class Solution {public static boolean increasingTriplet(int[] nums) {int a nums[0],b Integer.MAX_VALUE;for (int i 0; i nums.length; i) {if(nums[i] b){return true;} else if (nums[i] a) {a nums[i];}else if(nums[i] a){ b nums[i];}}return false;}
}
2.最长连续递增序列
题目链接. - 力扣LeetCode 思路双指针遍历
代码
class Solution {public int findLengthOfLCIS(int[] nums) {int n nums.length,ret 0;for (int i 0; i n; ) {int j i 1;while(j n nums[j] nums[j -1])j;ret Math.max(ret,j-i);i j;}return ret;}
}