Orderly Queue(LeetCode 899):

Problem