I'm a teen, I don't have a job as a programmer. I study programming at my school, though I didn't learn it in my school but through YT tutorials. Anyway, I've been doing programming for about 2 years and I find that when I do some kind of advanced tasks (student coding competition) I lose focus/attention after 5-10 minutes depending on the difficulty and I need to have about 5 seconds of refresh time to start again. I haven't been diagnosed with ADHD, but I have had people tell me that I'm hyperactive. Is this normal? Do I need more experience to build endurance? Do you guys have this happen to you?
Solving problems is a tough challenge. In general, I would always try to get off the screen - start drawing/writing down on paper some things about the problem - the constraints, some facts about it and then start brainstorming. In order to not lose focus, I break things down to smaller questions like these:
So, I try to decompose the solving process of the problem into smaller steps, which would be my "solving" strategy and then focus on each of these steps, having a little break between the steps to relax and enjoy the current outcome/breakthrough.
As a whole, the brain is powerful, but cannot focus on many things at a time, so decomposing your problem leaves smaller things to focus on and shows you that it's actually solvable and you can do it.
This isn't necessarily a bad thing. Sometimes you need to take a step back to refocus on the issue, approach it from a different perspective or simply not become frustrated. As long as you regain your focus, it's nothing to worry about.
Over time, you'll begin to think in larger "chunks" and your breaks will become more dispersed. You could try training your brain with some pomodoro-technique to improve - just adjust the times to what fits your brain.