资 源 简 介
判断一个序列(从1―N,N<=10)的出
栈序列是否合法,合法序列输出YES,非
法输出NO。
例如:N=3,输入序列:1 2 3 或1 3 2 或
2 1 3 或2 3 1 或3 2 1 均为合法。
输入:3 1 2 为非法。-Determine a sequence (from 1-N, N < = 10) sequence of the legality of the stack, the legitimate sequence of output YES, the illegal export of NO. For example: N = 3, input sequence: 1 2 3 or 1 3 2 or 2 1 3 or 2 3 1 or 3 2 1 are legitimate. Input: 3 1 2 to be illegal.