This year is full of mathematics.
Notice this api: Stream.takeWhile(Objects::nonNull)[.forEach() | .toList()];
Notice this api: Stream.collect(Collectors.groupingBy(l->l, Collectors.counting()))
I don't know what circuit this is, but it seems that the circuit can be seperated into four parts then LCM to the final result using sort of system chaos index.
Hard to explain the lagrange solution. See Visualize for BFS solution and math calculation.
Amazing! I finished both Solution1 and Solution2 in one shot!
This problem requires some data pattern examine. Thanks to the well-designed DAG, both parts have a brute force solution. But for Solution 1, topological sort DP solution will be NP-complete.
For part 2, BFS-based brute force solution will enlarge the Queue size to the same scale of DFS traversal times, which requires much more time for space reallocation comparing to DFS stack reallocation.
Linear algebra
Karger's algorithm.
| Lang | Regex URL |
|---|---|
| C++ | Modified ECMAScript from C++ |
| Java | Java EE Summary of regular-expression constructs |
| Python | Python Regular expression operations |