Pregunta de entrevista de Agoda

DP Problem Stack Problem based on stone sorting