Choosing a method for algorithmic problems – is it an art or science?


I’ve been doing lot of programming challenges lately (such as on leetcode.com) and often find myself in a situation when I cannot pick a method for solving a problem. I stuck with questions like – should I use brute force or greedy search would work better or maybe dynamic programming would do the job? Then I start coding a solution just too find out it does not work and I have to pick another method.

I wonder if there is a way to restate the problem in some abstract way and from there to see what solution technique would work for it?