+ 871 (div. 4)—28/3/2025 +
+
+ Div. 4 to practice implemenation skills + mathematical observations
+ thanks to
+ Paul Zeitz. From now on, I will only note useful problems.
+
+ -
+
- + B: typo, costing a few minutes. Go slower. Declare variables. + Think consistently through approach. + +
-
+ C: paused an found a general implementation as Zeitz advises
+ (starting with a general, non-mathematical solution: "The solution
+ is the earliest to get either both 1s at once or each over two
+ strings"). I still rushed, incorrectly computing the result
+ as
+
min(first, second)+ instead of +first + second. +
+ -
+ D: I looked up the recurrence relation \(T(n)=T(n/3)+T(2n/3)\) to
+ ensure it was sub-linear time.
+
+ Gain the mathematical skills to both analyze and derive (i.e. if + you forget) recurrence relations. +
+
+ -
+ E: spent forever fanagling with my Disjoint Set Union
+ template. I made countless errors including:
+
-
+
- + Not inserting nodes into the data structure before joining + them + +
- + Joining zero/non-zero nodes, corrupting the component graph + +
- + Erroneously updating component sums by double counting (i.e. + using a mutated value). + +
+ Understand data structures before you use them. Despite what + Colin Galen says, black-boxed knowledge often isn't enough. + Improve knowledge of Fenwick Trees, Segment Trees, and Union + Find. +
+
+ - + F: elegant approach and reduction, eliminating the need for a + graph traversal. + +
-
+ G: intentionally chose the mathematical/indexing method to
+ improve my skills. I'd also like to use
+
{upper,lower}_boundmore often with a lambda than + manually code binary search. + Once again, I practiced in a fundamentally flawed way, choosing + an approach I knew would be error prone and difficult. ++ Don't be scared if you initilly can't find an easy + implementation. + Reconceptualize, visualize, and reframe until something + comes up. Sometimes, this takes too long—however, my + threshold for that realization is MUCH too low. + Spend a longer time developing/considering approaches even if + you already know a feasible solution. Here, I spent ~5 minutes developing a solution, then 20 + minutes coding it. Instead, another 5 minute allocation of time + could lead me to the prefix sum solution, likely saving ~10 + minutes. +
+
+