Today I spent 75 minutes trying to solve a problem that turned out to not need solving. (It was to automate the one time conversion of something. It turned out the weren't enough of them that needed conversion to be worth automating).
There's that old joke about a company who's widget broke. The tried and tried to fix it and couldn't. Finally, the called their old, retired engineer. Begged him to come back and take a look, and said they'd pay him anything he asked.
He came back, looked at something for five minutes, put an X on a piece and said "This is what's broken and needs replaced. That will be $10,000".
The company asked for an itemized bill to justify such a large cost for such little time. The bill came in:
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
That is a good question...and I think the answer is "both". the knowledge is the part that lets him look at the broken widget and find out what works and what doesn't. Being able to do it in five minutes is where experience comes in.