I did manage to solve all three problems and I really liked the way the problems were put up on the website.
Anyway, I would still suggest trying for some more time before looking at the solution that that I have provided here - https://gist.github.com/849813 .
The first problem itself took me most of the time. All this time I was trying to come up with a optimal approach (and was stuck in some boundary condition in implementation for Approach 1) until I realized that even a brute force solution will work in this case because of the smaller text input.
Comments
I did manage to solve all three problems and I really liked the way the problems were put up on the website.
Anyway, I would still suggest trying for some more time before looking at the solution that that I have provided here - https://gist.github.com/849813 .
The first problem itself took me most of the time. All this time I was trying to come up with a optimal approach (and was stuck in some boundary condition in implementation for Approach 1) until I realized that even a brute force solution will work in this case because of the smaller text input.