Piyush and magical park test cases fail

Please can you check
My code is - https://ide.codingblocks.com/s/315698

hi sukrit,
the condition that you are checking at last (K) ,you are supposed to check that condition at every point.
Rest your code and logic is correct.
Please Let me know if you need any other help.