Crio.Do interview question

Intermediate Stack DSA question (Leetcode)