石家庄网站制作建设,wordpress数据库配置页面,樟木头镇网站建设公司,网站订单模板334. 递增的三元子序列
解题思路
找到的递增序列 不一定是连续的固定第一个数first 然后开始向后找第二个数second要求second 大于 first 找到之后 向后找第三个数third 找到 返回true如果third first 那么更新first third 重新找如果只是third first 更新second …334. 递增的三元子序列
解题思路
找到的递增序列 不一定是连续的固定第一个数first 然后开始向后找第二个数second要求second 大于 first 找到之后 向后找第三个数third 找到 返回true如果third first 那么更新first third 重新找如果只是third first 更新second
class Solution {public boolean increasingTriplet(int[] nums) {// 找到的递增序列 不一定是连续的// 固定第一个数first 然后开始向后找第二个数second// 要求second 大于 first 找到之后 向后找第三个数third 找到 返回true// 如果third first 那么更新first third 重新找// 如果只是third first 更新second int first nums[0];int second Integer.MAX_VALUE;for(int i 1; i nums.length; i){if(nums[i] second){// 说明找到了return true;}if(nums[i] first){first nums[i];}else if(nums[i] first){second nums[i];}}return false;}
}