The type of learning that involves problem-solving is called "insightful learning". This is a good way to learn in the sense that it really makes you understand that material.
It's insightful learning. It's said when a person sees the solution to a problem in the minds eye (problem solving rather than trial and error), it's insight.