The question was pretty straightforward. I’ve never done this problem before, but it looked fairly simple to me. I gave a quick approach to solve this problem. I was quite confident about my approach, and I saw a ray of hope actually to make it through.
Tip: Well, no matter how simple the question is, never get overconfident. Please spend some time thinking about how you’ll implement it before actually starting to code the solution.
Well, this question looks quite simple. But unfortunately, it turns out the implementation is not so straightforward. You have to take care of a lot of special cases. I got overconfident and didn’t think about the special cases. Because I hadn’t given enough time to think about the implementation, I was having a hard time coding it on the fly. However, I completed my code fairly quickly.