Beginner problem based on Queue "Little Monk and Goblet of Fire"

Problem: https://www.hackerearth.com/practice/data-structures/queues/basics-of-queues/practice-problems/algorithm/little-monk-and-goblet-of-fire/description/

My code: https://pastebin.com/br1nePCP

I have simply used brute force.

input:
14
E 1 1
E 2 1
E 1 2
E 2 2
E 1 3
E 3 1
E 3 2
D
D
D
D
D
D
D

output://getting
1 3
1 2
1 1
2 2
2 1
3 2
3 1

//should be
1 1
1 2
1 3
2 1
2 2
3 1
3 2

What’s wrong with my code? Thanks.

1 Like