题目描述
Given a sequence of n integers a1, a2, …, an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a list of n numbers as input and checks whether there is a 132 pattern in the list.
n will be less than 20,000.
测试数据
Given nums = [1, 2, 3, 4]
return False // There is no 132 pattern in the sequence.
Given nums = [3, 1, 4, 2]
return True // There is a 132 pattern in the sequence: [1, 4, 2].
解题思路
找满足A[i] < A[k]
C实现代码
#include <stdio.h>
#define true 1
#define false 0