> For the complete documentation index, see [llms.txt](https://emmaguo100.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://emmaguo100.gitbook.io/leetcode/334.-increasing-triplet-subsequence.md).

# 334. Increasing Triplet Subsequence

```
// Some code
class Solution {
    public boolean increasingTriplet(int[] nums) {
        if (nums.length < 3) return false;
        ArrayList<Integer> list = new ArrayList<>();
        list.add(nums[0]);
        for (int i = 1; i < nums.length; i++){
            if (nums[i] > list.get(list.size() - 1)){
                list.add(nums[i]);
                if (list.size() >= 3) return true;
            } else{
                int j = 0;
                while (list.get(j) < nums[i]){
                    j++;
                }
                list.set(j, nums[i]);
                
            }
        }
        return false;
    }
}
```
