334. Increasing Triplet Subsequence

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了334. Increasing Triplet Subsequence相关的知识,希望对你有一定的参考价值。

https://leetcode.com/problems/increasing-triplet-subsequence/#/description

http://www.cnblogs.com/EdwardLiu/p/6092267.html

这个解法的思想也可以推广到任意 k k比较小或者为常数的情
况,毕竟对于常数 k O(k) = O(1).

public class Solution {
    public boolean increasingTriplet(int[] nums) {
        int small = Integer.MAX_VALUE, big = Integer.MAX_VALUE;
        for (int n : nums) {
            if (n <= small) {
                small = n;
            }
            else if (n <= big) {
                big = n;
            }
            else return true;
        }
        return false;
    }
}

  

以上是关于334. Increasing Triplet Subsequence的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode 334. Increasing Triplet Subsequence

334. Increasing Triplet Subsequence

334. Increasing Triplet Subsequence

LeetCode-334. Increasing Triplet Subsequence

334. Increasing Triplet Subsequence

334. Increasing Triplet Subsequence