How do I improve my problem solving/thinking skills

I am really struggling to finish the intermediate algorithm challenges and really have been spending too much time on them. I don’t know what I can do to improve my approach. I read the problem, comprehend it and write down my logic down on paper. I can only go so far until I don’t know how to go any further. For instance:

  • I don’t know how many variables I’ll need.
  • How to think of multiple approaches that work

Please provide tips on what I can do.

Completely normal. Some of those are hard.

Define “too much time”. Learning can be a long process. You are learning - be proud of that.

Some of that is an instinct that develops over time. It develops by doing it.

I caught one of those cooking challenge shows. I can’t remember which one. It was the one with Gordon Ramsey on it. Anyway, one of the challenges, he decides to join it. They all have an hour to make a dish with whatever ingredients. Everyone is stunned when Ramsey doesn’t start cooking immediately. The contestants are working frantically, while Ramsey just walks around, gives the other contestants suggestions, chats with the judges. 10 minutes go by. 20, 30. The contestants are freaking out that they won’t have enough time to finish. Finally, with only 20 minutes left, Ramsey walks over to his station and starts working. He’s calm and focused. He has it all planned out in his head. He looks like a zen master, moving calmly and assuredly, flawlessly. While the others are desperately freaking out in the last minutes, Ramsey calmly finishes his amazing dish and plates it with panache with 10 seconds to spare.

It took him years to develop that skill. He got it by doing a lot of cooking. In the process, I’m sure he burned a lot of omelettes. I’m sure he collapsed a lot of soufles. But over time he got better. He honed his skills and his instincts. He could probably open my fridge and look at my spice rack and instantly plan out a 5-course meal.

You want to look at coding problem and instantly know what approach is best and how to structure it? Then code. Code a lot. Write bad code if that is all you can do. If you write enough bad code, eventually you’ll start writing good code.

You mentioned multiple approaches? After I finished each challenge, I would do a google search for other people doing it. There are some cool youtube videos. Sometimes they had a better approach. Sometimes they had just a different approach. Sometimes they had the same approach as mine but did it better. Sometimes worse.

Just code, code, code. Your Spidey Sense for algorithms will improve. You can also read books on algorithms and computer science.

3 Likes

I’d say I’ve been in the intermediate section for a couple of months.

I don’t have the stats here, but that may be a bit long, or it may be just right depending on the amount of time you invest in it and your background.

But you’re learning. I might suggest this.

  1. Break the problem into small pieces, a series of tasks. These will become functions.

  2. Try to code the algorithm. If you fail, take a day off and try again. If you fail again, do it again.

  3. Ask the forum for a hint. Make it clear that you aren’t looking for the full answer, just a hint for an approach.

  4. If you can generalize the problem, do a google search to look for approaches to similar problems. Maybe take a peek for a hint.

  5. If you get absolutely stuck, show the forum what you have and ask for a hint. If you can post your code (or better yet, a link to a pen) then we can help you. Tell us what you want it to do, and what it is doing instead. Be specific.

  6. For some of these problems, people on youtube code the problem as you watch. Just watch, and then tomorrow, try to do it from scratch.

  7. After you finish the problem, look for other solutions. Try to understand them.

Seriously, just keep working at it. Some people pick this up quickly. Some struggle. But everyone gets it eventually. Who knows? Maybe the people that struggle have it better because they learn how to search and work hard.

1 Like

Sometimes, it’s much better to figure the algorithm out on paper than it is to just code it.

This is because most solutions to problems already exist in the physical world as a manual process. Most problems are easier to think through in your hand or using elementary techniques like writing down a number like containing in a variable or using your finger to “index” through a list of numbers or characters in a string.

Once you can deliberately create your solution manually, then it’s time to code it out. Even in the working environment, you’re creating manual solutions before you are ever coding one. However, it makes one’s job less frustrating when already have an solution put together.