I think
ThePhantomUpvoter is correct: you should use whatever technique is more appropriate for:
- The problem complexity.
- Your skills.
For instance, suppose the problem is 'easy'', then you can (and probably should) use the
Joan Murt's approach: design the right algorithm, covering all the test cases.
On the other hand, suppose the problem is very difficult or you are lacking the required skills (or experience): you have to go through a more complex approach, for instance implementing a simple, not complete algorithm, suitable only for covering a small subset of the test cases. Then you might go on improving (or re-desing from scratch) such algorithm, based on the experience gained.
My two cents.