Major algorithms to know for Leetcode and interviews

Hey guys,

Sometimes, when facing a new problem, you need to have ideas and/or tricks (not talking about data structures) that one could not come up with upon seeing them for the first time - except for some people of course. And it is quite frustrating to block on a problem that you could solve if you just had the knowledge.

Here is a list of what I could think of right now, that I mainly discovered through videos when studying a topic or in Leetcode solutions, but is there anything else that you would see worth mentioning?

I think this would be helpful for some people (and me) :)

Negative marking (trick)
Line sweep (trick, it has its dedicated category, but much more problems can actually be solved using this)
Kahn's algorithm (topological sort)
Kruskal's algorithm (minimum spanning tree)
Prim's algorithm (minimum spanning tree)
Dijkstra's algorithm (shortest path)
Kadane's algorithm (maximum sum subarray)
Hierholzer's algorithm (eulerian circuit)
Knuth-Morris-Pratt algorithm (string matching)
Floyd's cycle detection algorithm (cycle detection)
Boyer-Moore algorithm (majority finder)
Sieve of Eratosthenes (prime numbers)

Later additions:
Rabin-Karp algorithm (string matching)
Kuhn-Munkres/Hungarian algorithm (assignment optimization)

Cheers!

Berthouille

Comments (7)