Jan-27-2017, 12:42 AM
OP = original post.
Too many students say they're not students, so we have to assume it, please don't take it personally :)
(Even if it's on Leetcode, someone could have assigned it.)
As for the failure - as mentioned, your code is inefficient. It's quadratic where linear solutions are possible (some of us have been PMing them for fun, and someone else posted a spoiler that was deleted). This may be why it's failing, if you're confident that the logic is correct. It looks fine to me.
If you don't know what I'm talking about, try start here and if you still have questions feel free to post them on this thread and we'll help you optimize your solution.
Too many students say they're not students, so we have to assume it, please don't take it personally :)
(Even if it's on Leetcode, someone could have assigned it.)
As for the failure - as mentioned, your code is inefficient. It's quadratic where linear solutions are possible (some of us have been PMing them for fun, and someone else posted a spoiler that was deleted). This may be why it's failing, if you're confident that the logic is correct. It looks fine to me.
If you don't know what I'm talking about, try start here and if you still have questions feel free to post them on this thread and we'll help you optimize your solution.