1
$\begingroup$

In order to keep my interviewing skills sharp, I solve one algorithm/data-structure problem every day, from sites like Leetcode or HackerRank.

If I am not able to solve it after 45 minutes or so, I usually refer to the solution. I review it, understand it, and move on.

However, I have found that I do not really learn anything at all by looking at the solution. Even though I understand the solution at that point in time, it doesn't really stick with me. I am not able to learn the approach and trick of that solution, for purposes of retaining and utilizing it later. And, if I ran into a similar question in the future, I would not remember how to utilize the approach that I have definitely seen before.

What is your technique or suggestion in learning such approaches/techniques in solving algorithm/data-structure problems?

If this question is not in the right Stack Exchange please let me know.

$\endgroup$
  • 2
    $\begingroup$ How long have you been trying your approach? It might not be bad as you may think it is. I'll suggest in order to strengthen your comprehension of the material: try to make an overview per algorithm technique you have studied. Also, keep a list of a few, key, examples. You might want to check some cheatsheet to guide you, but you must try to do it yourself. At the same time, keep working solving problems. As with any other matter, mastery becomes with practice. $\endgroup$ – jonaprieto Feb 14 at 10:38
  • $\begingroup$ I have usually done it for like up to 1 month at a time. This month, I have been doing problems every day. However, I do not feel that I am getting on the next gear. A cheatsheet would be nice, but that worries me because it might make me take a memorization approach. But I suppose if I was able to come up with some clear way to specify how a specific solution works. That could be beneficial in the future. Do you have any approaches or samples of you doing this? $\endgroup$ – Don Code Feb 14 at 23:37
1
$\begingroup$

To be an algorithm designer, you have to do some steps.

First, learn the basics of algorithmic thinking. You can learn it by using a simple programming language book. Choosing the language is not important. You can take a look at this page for finding a book. After finishing this step, you have to be able to present pseudocode (or code written in a specific language) for simple problems, for example:

  • Searching in a list: there is a list of numbers, and we want to see a specific number is in the list or not.
  • Sorting a list
  • Finding the greatest common divisor of two numbers

Second, learn the important data structures— link-list, stack, queue, and tree— and their algorithms. For doing this step, you can read the books of data structure written for bachelor students of computer science. For example, Fundamentals of Data Structures by Ellis Horowitz and Sartaj Sahni is a good book. At the end of this step, you have to know/do the following things:

  • What is a data structure? How we can iterate over the elements of a data structure? How we can add a new item(/remove an item) from the data structure?
  • What are the main features of each data structure?

Third, learn conventional algorithm design techniques— divide and conquer, dynamic programming, greedy, back-track, branch and bound. For doing this step, you can read the algorithm design books written for bachelor students of computer science. For example:

  • Foundations Of Algorithms, Richard Neapolitan
  • Introduction to Algorithms, Thomas H. Cormen, et al. (Chapters 1-17) After doing this step, you can solve a large range of algorithmic problems, like the problems that can be found on this website: onlinejudge.org.

Forth, learn specialized algorithm design techniques, like randomized algorithmic techniques, parallel algorithmic techniques, distributed algorithmic techniques, approximation algorithmic techniques, etc. For each case, there are some books written for graduate students of computer science.

Besides, there are some other steps, like learning the basics of the theory of computing, complexity classes (NP-complete and P-complete theories), and a lot of other things. It depends on your goal and the level that you want to be reached.

$\endgroup$
  • $\begingroup$ To round out your skills, learn the language you use most well, but check out some other languages with different objectives for perspective (i.e., learn a bit of Python -- it is a very flexible language, that is used quite a bit "in earnest", search for Downey's "Think Python", 2nd edition for a gentle introduction --, take a peek at some functional language and see how you can do magic with recursion) $\endgroup$ – vonbrand Feb 16 at 1:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.