Cannot get the solution in my head!
By: Shreya Sahu
Tags: Coding, Brute Force, Mentoring, Questions, Optimizing

As of now, I think I need a guide who can have hands upon me like telling me where did I go wrong while solving the problem. Like wise, solutions seeing and understanding will help me too, though I haven’t tried that yet. Maybe because the first time I attempted understanding the solution, the brute force itself was way ahead of my mind. I’m overcoming that fear, I’m trying.

Regarding the first paragraph, there is no easy way to put this for you — nobody will do this. That’s literally handholding, and unless you have a friend circle who are coding together or helping each other out, a hand over you guiding you with your every solution — it’s very hard to find and will make you dependent.

And this is where the internet is a beautiful place :)

Google does not judge you on what you put in the search bar

People have put thousands of stupid questions in StackOverflow, and others have helped them out too :)

Discussion portals in websites are literally free gold. People put out their solutions there, for you to look and learn from

When you are beginning, do not jump into algorithmically hard questions directly. That’ll further take your confidence down. And we do not want to start a cycle of demotivation, right? Instead, we want to take the path which gradually increases your confidence, and challenges you in achievable and motivating ways. And that’s where I’d mention it again — Get your fundamentals, the lego blocks right. Solve enough easy and medium questions on linked lists, binary trees, stacks, queues, recursion, such that you have a rock-solid understanding of the concepts and why these DS exist. Because these will be your tools going forward.

A recommendation is: Pick up a topic, say a binary tree. Pick up a portal, hackerrank link I shared is a good one or leetcode, you have many more options. Sort and solve the questions set by easy, then medium. It’s okay to not do hard questions when you’re starting afresh. For each question, try to at least come up with the brute force on your own. And then think about optimizing. The performance report of your solution will guide you. If not able to think about the optimization on your own, remind yourself that we are still learning and improving :)

Remember, we improve iteratively :)

Couple more points I’d like to tell you are — Taking the coding scenario in mind

1) How to know when to ask for help?

You ask for help too early and too often, and you haven’t exercised your mind enough, plus the other person will get annoyed as well. Ask for help too late, and you waste a lot of time on one question. How to find the silver line?

Think in terms of your tools — the DS. There are only x of them!

And timebox your thinking — say you put a timer for dedicated struggling on that question for 20 mins. If no leads at the end of 20 mins, it’s time to ask for help.

Asking for help can be in person, or over the internet. If you search a little, there are may telegram or discourse groups which code together. Might want to try those?

2) How to ask questions?

This is really crucial. While your time is important, you have to value the other person’s time too, and you want to give them as many details as possible.

In your questions, online or else — talk about what you have done till now, in crisp points.

Say,

“Hello — I’ve been stuck at this question for a while — ‘THE QUESTION’”

What I’ve done till now is :

1) Approach 1 — and why you think it’s not doing good?

2) Approach 2 — and what you think it’s not good enough?

This’ll provide a clear picture of what kind of help you’re looking for, and at what stage you’re in your solution.

Also, a psychological hack that works for me is — when I am asking someone something, I do not wanna look dumb. So I try to think in every direction where my mind can stretch before reaching out for help. Then whatever input I get, that’s learning :D

Let’s sync up again after a week.

Try these techniques mentioned, and do reach out to me after a week (Or before as well, if you have something specific to ask)

Remember, we are learning and growing and being better, it is a great place to make mistakes, and figure out our shortcoming — only to work on them :)