As an analogue, you and I can memorize speeches relatively easily in our native tongues (I would suppose it's fair to say we're domain experts in the languages we know), but it's not easy at all to memorize and repeat (a) random strings of sounds, or (b) sentences from languages that don't have any common base with the languages we know.
Experts can write the focal elements (e.g. pseudocode) first and then expand them into a full program. A good example might be the fizzbuzz test, or generating the permutations of a string, you'll have an idea of what the problem involves because you've done it before. If you can't visualize the problem in terms of something familiar, you'll have a hard time taking a top-down (e.g. memory-recall-based) approach.
They once did an experiment where they sat outside with her and a truck drove past with a particular chessboard configuration on the side. She glanced at it, then recreated the entire board in a few seconds. Then another truck drove past with a different configuration and she couldn't recreate it. She remembered the first one because it was from a game she'd seen before. She'd never seen the second one before so she couldn't remember it.