sanjar-notes / dsa

C++ basics, Data structures and algorithms.
https://sanjar-notes.github.io/dsa/
16 stars 9 forks source link

"Kind of DnC" - using partitioning as a way to avoid brute-force enumeration #15

Open sanjarcode opened 2 years ago

sanjarcode commented 2 years ago

There are times in DnC when we use partitioning of problems just for the sake of avoiding brute force enumeration, and we may not combine solutions to subproblems at all.

Maybe this is not DnC, but it's an alternative to brute-force enumeration.

Here's a problem that I solved using this "kind of DnC" approach: https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k/