If you have a bruteforce solution of a problem and your new approach is giving you Wrong Answer , Then you can just use this to find the corner case. Please share if you have a better approach
I had made something similar. Check this out. You can test python, java and C++ solutions.