Open sanjarcode opened 2 years ago
Also, it's important to solve non-classic problems that use DnC (e.g. just knowing merge sort as a way to do DnC is not good enough). My way is this - write two functions - helper and combine. combine
does solution re-combination (the second half of DnC). The helper
does just one thing - it solves partitions of the problem, and combines the solutions using combine
.
Closely related, https://github.com/sanjar-notes/dsa_with_cpp/issues/15
I first encountered the problem here. Dividing into halves doesn't work here because the minimum problem size is > 2 (4 in this case).
Questions:
https://leetcode.com/submissions/detail/740514206/