Author: Bhuvnesh Jain
Tester: Ankit Sultana
Editorialist: Bhuvnesh Jain
Basic Looping techniques
Find any valid sequence of magic operations so that all the cards face upwards.
The only observation for this problem required is that the magic operation on the rightmost card affects only itself and not any other card.
So, we simply do a linear scan from left to right and whenever we encounter a card facing down, we perform the magic operation on it. This solution will tak atmost O(n) steps as we can perform the magic operation on all the elements in the worst case. As per the constraints, k >= n, so the above solution will work.