How to solve these kind of problems? Is there any algorithm or so? This is a problem(Name: Admin Blues) from July challenge from Edyst Platform which is already over many days back…

This feels like a backtracking problem. You can look up easier problems tagged `backtracking`

in leetcode or HackerRank. If you are new to backtracking then this problem might be a little tough for you. I’d suggest you solve a couple of easy problems and understand how it works first, and then you can attempt this.

Backtracking algorithms generally have exponential runtime. Here as \text{ID} <= 10, an \mathcal O(2^n) solution will run under 1 second.

Ok since it was supposed to be a practice question for Codevita, I didn’t expect it to be hard. I thought I was missing something or there’s a convenient algorithm which I don’t know since brute-force for this problem seemed too hard to implement for me. Yeah, I’m a little weak in implementing recursive and backtracking solutions to new unseen problems. Thanks for the suggestion… I will try a few easier problem first then…