I've been melting my brain with leetcode. Some highlights.
I really enjoy doing a Topological Sort, or Kahn's Algorithm. Almost every graph problem I see, I take a minute and have a think if it can be solved with a topological sort.
I took a day to really try to understand Monotonic Stacks or Deques, because on the face of it I couldn't grasp what they were doing at all. But after manually stepping through a few examples of the algorithm on paper it clicked. Been redoing a bunch of stack problems seeing if they can be solved with a Monotonic solutions.
Floyd's Cycle Detection remains a blind spot for me. I mean, I get it, but I often fail to perceive that a given problem can be reinterpreted as a cycle detection problem.
Solving shortest cost problems in a graph with a minheap was something I'm not sure I ever learned in school. I always remember doing that with a breadth first search queue.
I wonder if that had anything to do with learning all this in C/C++ without any standard template libraries. If we wanted to use a minheap to solve a problem, we would have had to code one up ourselves, and I'm not sure we were taught that in undergrad. Least I never was. Doing the leetcode problems in modern languages, or even C++ with STL seems mostly to be a matter of picking the right data structure off the shelf and solving the problem with it and/or having heard of the algorithm you never would have come up with yourself.
Also, having been a software engineer for 20 years already, it has me looking back over my career. Over all the stitching together of off the shelf libraries I've done, wondering if at any point I could have done a better job with any of this. The answer is absolutely not.
I've been melting my brain with leetcode. Some highlights.
I really enjoy doing a Topological Sort, or Kahn's Algorithm. Almost every graph problem I see, I take a minute and have a think if it can be solved with a topological sort.
I took a day to really try to understand Monotonic Stacks or Deques, because on the face of it I couldn't grasp what they were doing at all. But after manually stepping through a few examples of the algorithm on paper it clicked. Been redoing a bunch of stack problems seeing if they can be solved with a Monotonic solutions.
Floyd's Cycle Detection remains a blind spot for me. I mean, I get it, but I often fail to perceive that a given problem can be reinterpreted as a cycle detection problem.
Solving shortest cost problems in a graph with a minheap was something I'm not sure I ever learned in school. I always remember doing that with a breadth first search queue.
I wonder if that had anything to do with learning all this in C/C++ without any standard template libraries. If we wanted to use a minheap to solve a problem, we would have had to code one up ourselves, and I'm not sure we were taught that in undergrad. Least I never was. Doing the leetcode problems in modern languages, or even C++ with STL seems mostly to be a matter of picking the right data structure off the shelf and solving the problem with it and/or having heard of the algorithm you never would have come up with yourself.
Also, having been a software engineer for 20 years already, it has me looking back over my career. Over all the stitching together of off the shelf libraries I've done, wondering if at any point I could have done a better job with any of this. The answer is absolutely not.
Ah well.
More options
Context Copy link