Rubber duck problem solving describes the phenomenon where you realize the solution to a problem in the middle of explaining it to someone else. The name stems from apocryphal stories in which stumped engineers are advised to get help from inanimate objects, including a literal rubber duck.
The technique works because communication forces us to arrange our thoughts and prevents us from taking shortcuts that would leave our audience behind. As one developer explains:
When you force yourself to verbalize something, you take poorly formed mind-stuff and slot it into discretely packaged concepts (words) whose meanings are agreed upon by other humans. This alone adds an important layer of organization to your thinking by taking non-verbal soup and giving it shape.