How to improve logical thinking?
For example, if I encounter a challenging mathematical or computing problem, after a few minutes when I still can't figure out the answer to it, my brain just "gives up" and won't think anymore no matter how hard I try.
Another one is when I encounter a complicated for loop, it seems that my brain can iterate and imagine only a few loops and "gives up" again right after that. I can't make my brain think deeper. This makes reading other people's code a bit hard for me.
Reason I ask is I dream to be a good programmer someday and work in a good company. I know that a lot of them require you to be good in algorithms and problem solving, which is why I'm very worried right now.
Has anyone else been in this position? What can I do to improve my thinking?