Big-O complexities of hints

I was wondering if the Big-O of the solutions for the “JavaScript Algorithms and Data Structures Certification” course could be included in the hints.
The solutions are helpful and different but sometimes they could be confusing as to which one is the best.
I think it would be better if the complexities are included in the posts so that we’d learn how to come up with efficient solutions and get good at figuring out the Big-O of our solution along the way.

I’m not sure that the big O would help on many of the problems, but it would be an interesting addition for some of them. The primes problems do have some discussion of performance, if I recall correctly.

I’d be careful worrying too much about big O though. ‘Is it fast enough’ depends upon context. Instead of chasing big O, it is often better to figure out what is the most time consuming parts of your code and speed those parts up. You sometimes pick an algorithm with a slower big O because it’s easier to read and maintain and is not a bottleneck in your code.

2 Likes

Most of the time in web applications, you do not need the most efficient solution. Instead, you need a solution that is readable, maintainable, and most importantly that it works. The only time you need to worry about the most efficient solution is if a solution is not fast enough for the task at hand. You will judge that on a case by case basis.

A few years back, I pondered the idea of adding the Big-O for each solution, but the time it would have taken did not justify the gain. Most content on FCC is created by unpaid volunteers, so the focus is to provide enough information in the guides so users can solve the challenges. Anything beyond can be discussed in a forum post if users want to know more.

3 Likes