Back to Problem Solutions forum
I'm trying to learn programming and work through some of the problems on here and a few other sites with exercise problems. I am also trying to read an intro book to Data Structures and Algorithms.
On some parts I get kind of stuck/confused or use a really hacky and probably un-'pythonic' way to solve it. Should I be trying to sit and totally understand it before moving on or just keep going and hope that it makes sense later?
Hi Friend! Funny, but probably important question!
As you probably guessed yourself, the answer is Generally - NO - there are multiple ways to progress and it is ok to explore many of them. No need to sit in self-demotivating position (generally).
You may note that problems at this site are not in any specific order, but just are going as they were added and sorted by number of solutions. This means first are generally simpler, just that.
Similar is with books, though authors usually has better control on how to compose material. Anyway often author may wish that reader can get slight understanding in different matters before diving deep in this or that specific direction.
or just keep going and hope that it makes sense later?
So generally this makes sense. The only thing to beware is - some people never look back to revise their older works and troubles. This is no good. It is important to try analyzing others solutions sometimes, compare your own approaches.
Otherwise, as happens to some people, patience plays bad trick and person may solve dozens of simple problems without learning much :)
Is it normal to feel really stupid on some problems? I lack the mathematics knowledge for a lot of common questions, or knowing how to think through the problem.
Is it worthwhile for me to revise earlier math or can you be a computer scientist without solid math skills?
If you want to understand alghorithms, data structures and how things work under the hood you just have to improve your math.
However it's not neccesary to "know" the math to be developer (I know some people who are actually dumb in math but they are developers), unless you want to learn data science or machine learning.
It's just my opinion, not the ultimate truth.
Should I stick to web development in that case? I live in Canada and I want to change my career to Tech so I'm trying to learn as much as I can right now.
I was trying to work through some problems on Leetcode too since that's what they'd actually ask for in interviews (apparently) and I feel really dumb even though I'm half-way through reading a beginner's algorithms book.
It's been my experience (30+ years as a developer) that about 95% of the needs in IT are covered by basic arithmetic, lists and dictionaries (maps)... sometimes a tree or a graph. A lot of the work in the business world is "get data from somewhere, apply business rules, save to database, repeat". It's often enough to just know that a method to solve some kind of particular problem exists, so that when you come across a particularly tough problem, you remember seeing some way of solving it more efficiently.
So you don't need to worry about memorizing or understanding completely each and every algorithm and data structure; being able to remember that you've seen something somewhat similar is enough. Or even if you don't remember seeing anything that fits, often searching the web for a while will point you in the right direction.
Also, with most modern languages, you have huge libraries available that have already implemented a lot of well-known and often-used algoritms and structures. I've written stacks and queues for small problems on sites like CodeAbbey, but I've never written one to use in production. With .Net, I'll use Stack<T> or Queue<T> so that I get library support, or can change to ConcurrentStack<T> if I want to use many threads.
This is about you expanding your knowledge and testing yourself.
This is not a educational course where you're expected to do each one in order.
If you're getting burned out on a problem, step back for a bit and come back to it later.
Try the next problem.
Go for a run.
Get something to eat.
Play a game.
You'll be less stressed and you'll have opportunities away from the keyboard for concepts and ideas to "snap in" (This has happened to me quite often. Especially in the shower or right before falling asleep.)
And in your attempts at other problems, you could develop the methedology needed to figure out the skipped one.
The puzzle number does not necessarily reflect difficulty. I got stuck on #22 for a really long time because I couldn't grasp the method for getting the answer.
I walked away from it. And not just for a day or two. When I came back later, for whatever reason, it just clicke. I couldn't tell you what changed but I saw the problem differntly and solved it.
You said "Is it normal to feel really stupid on some problems?" Hell yes it is. Completely normal.
I'm stuck on a problem right now and feel silly because I just can't code it correctly. It can be frustrating.
If you're struggling, it's OK to ask for help understanding something.
There's a HUGE difference between asking for an answer and asking to be taught a concept or method.
Us coders should be striving to help each other become better coders.