2265 LeetCode problem solution
LeetCode 2265 problem is a good example of DFS with postorder traversal. For each node, we calculate the sum and number of nodes in its subtree.
Read moreLeetCode 2265 problem is a good example of DFS with postorder traversal. For each node, we calculate the sum and number of nodes in its subtree.
Read moreLeetCode 4000 Largest Integer With Given Digit Sum is a simple greedy problem. To build the largest possible number, we place the largest digits first while keeping the required digit sum.
Read moreLeetCode 3870 and 3871 problems look almost the same, but the larger constraints change the solution. This is a good example of why you should always ask about the problem constraints.
Read moreLeetCode 3871 Count Commas in Range II solution in Elixir. In this solution the recursion replaces the C++ loop. Since it uses tail recursion, the Elixir/Erlang VM can execute it without accumulating stack frames.
Read moreLeetCode 3871 Count Commas in Range II solution. It extends the 3870 problem to much larger numbers. Instead of counting numbers, we count each comma level separately in O(log n) time. But for the given constraints, the algorithm performs at most five iterations and O(1) time.
Read more