
Recent Posts
Recent Comments
Archives
Categories
Meta
Category Archives: Algorithms & Data structures
C++: Unordered maps and sets for nonprimitive types
Since C++ 11, we can use unordered sets and unordered maps. However, these data structures only seem to work with primitive types and strings. If you need a pair or a vector as the key, you’re out of luck. Fortunately, … Continue reading
QuickSelect
Theory Quickselect on Wikipedia Implementation in C++ Practice https://leetcode.com/problems/kthlargestelementinanarray/
Fenwick tree (aka Binary Indexed Tree)
Theory TopCoder – Binary Indexed Trees Algorithms Live – Fenwick tree Wikipedia – Fenwick tree Implementation in C++ Practice Kattis – Movie collection AtCoder – B Fenwick Tree
Disjoint Set Union (aka UnionFind)
Theory Algorithms, 4th edition by Robert Sedgewick, Kevin Wayne 1.5 Case Study: UnionFind Union Find on Cubits.ai Implementation in C++ Practice https://atcoder.jp/contests/practice2/tasks/practice2_a
Isolate the rightmost (leastsignificant) bit
Fast & elegant: Tests Output Brute force Output for the new version Practice 231. Power of Two 191. Number of 1 Bits Related concepts Two’s complement
Posted in Algorithms & Data structures, Posts, ShortPosts
Leave a comment
Kadane’s algorithm
I just learned about this algorithm, which is considered a dynamic programming approach. However, depending on the implementation, it might not resemble dynamic programming at all. Check out the implementation presented on Wikipedia: That does not look like dynamic programming … Continue reading
Posted in Algorithms & Data structures, Posts
Leave a comment
Interesting programming problems
The following problems were either difficult to solve, provided a valuable learning, or both. I’m putting them here so as not to forget a bout them. Drinks Three Pairwise Maximums FashionabLee Captain Flint and Crew Recruitment
Posted in Algorithms & Data structures, Posts
Leave a comment
Algorithms live, Episode 0 – Notes
One of my goals this year is to catch up with Algorithms Live and as part of that, I’ll be posting my notes for each episode and possibly the solutions to the proposed problems. Episode https://www.youtube.com/watch?v=kPaJfAUwViYSorry, as of now I … Continue reading
Posted in Algorithms & Data structures, Posts
Leave a comment