Hello Codeforces, I was solving this problem on hackerrank.
I successfully solved it by submitting this. All test cases passed.
But this submission fails on thistest case. Why??
Also when i try to implement the above solutions on my computer they run indefinitely on other test cases(which got accepted on hackerrank) for large values of n and m.
Help!!