Random things I’ve found during leetcode. This serves as a list of things I should either try to understand, or I finally did end up understanding. I’ll try to put the description of those things here.
- From this comment on a leetcode of the day
- KMP algorithm for finding a prefix in another string
- Z-algorithm, another pattern search algo
- Rabin-Karp algorithm, another string searching algo related to rolling hashes, which I swear I learned about at some point in college but now I don’t remember…
- From LC 2429:
- To unset the rightmost bit, use the following:
x | (x - 1)
- To set the rightmost bit, use the following:
x & (x + 1)
- This stuff feels like magic, but it makes a lot of sense when you work through the examples. To get an intuition of it, just write down a couple of examples and try it out
- To unset the rightmost bit, use the following: