It got WA verdict during the contest last week but the similar solution is mentioned in the editorial.
LINK TO THE EDITORIAL
When I commented on the same and posted the link to my solution there, the author @panik replied ->
" I am looking into your solution although its giving the correct ans on codechef compiler on the TC on which your solution is showing wrong, i am looking into it."
On codeforces posts, someone suggested with possible test cases and errors, it’s giving correct answer on every such case.
Till now, there is no reply from the Author.
Moral of the story : Can anyone please let me know what’s actually my mistake in the code?