I always try to keep my spirit up and not to be demotivated. But sometimes I feel so pessimistic about learning algorithms.
Yeah, join the club. I know things are tough in the apocalypse, but one of the best things I did was join some local meetups. Talking with other developers I found out that my frustrations were completely normal.
I just want to improve my logical thinking and desire to become excellent in algorithms.
It’s like a muscle - the more you use it the stronger you get. Some people naturally have a lot of muscle, some very little. But everyone can get stronger if they work at it. Maybe I’ll never be big like Arnie, but if I work hard, I can accomplish a lot and be the best version of me I can be.
I understand an algorithm is not only a JavaScript thing.
Right, but just to emphasize, it is completely language independent. I actually once as an experiment wrote out the pseudocode to a bubble sort and walked my wife (who is very smart, but know nothing about computers and struggles with math) through it. Once I explained it, it made perfect sense to her. We put some numbers on some note cards and she was able to do it no problem. This is a woman who has never coded in her life.
As Leggo points out, there are two issues here: 1) Figuring out the algorithm. 2) Understanding how to implement it in JS. Most algorithms don’t involve crazy JS so the issue is usually the first one. Before I even think about JS, I try to understand the challenge. Just like in walking my wife through a sort algorithm, I try to imagine it - in that case, a stack of cards makes sense. If you can, try to understand what is happening on a conceptual level. Without thinking about a computer language, how would you solve this if it were a problem in the physical world (acknowledging the limitations that computers will have, in general). If it is too complex for my brain, I may use a whiteboard and/or get some actual physical cards.
But what will you advise whether I should learn algorithms problems only on FCC or should also take any other course?
I have always said that FCC is a great framework for learning, but probably won’t be your only source - it is not comprehensive. I had to take a lot of little side trips.
So yeah, learn from other place. I like the site leetcode.com, but there are others. There are also countless videos of people solving various algorithms. I would definitely want to look at those after I solve the problem - if for no other reason just to have a window into how someone else thought of this problem. I also recommend the book Cracking the Coding Interview - it’s a great resource with a lot of great information, notably a big section on algorithms. It’s in Java, but that’s OK since the algorithm is the important thing. You can also go online and people will actually walk you through some of the interview questions they’ve gotten - very informative.
But again, take a deep breath, this stuff is hard, take your time. If you put in the time, you will improve.