Validate stack permutation based on triplet condition

Related Tags

Validate stack permutation based on triplet condition - Coding Problem | K5kC