Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dividing problem into "very small halves" for DnC may not always work #14

Open
sanjarcode opened this issue Jul 7, 2022 · 2 comments
Open
Assignees

Comments

@sanjarcode
Copy link
Member

sanjarcode commented Jul 7, 2022

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:

  1. Can it be made to work by doing halfsies?
  2. If not, how to divide the problem then?

https://leetcode.com/submissions/detail/740514206/

@sanjarcode sanjarcode self-assigned this Jul 7, 2022
@sanjarcode sanjarcode changed the title Dividing problem into how many sections for DnC minimum problem size > 2 Dividing problem into halves for DnC doesn't always work Jul 7, 2022
@sanjarcode sanjarcode changed the title Dividing problem into halves for DnC doesn't always work Dividing problem into halves for DnC may not always work Jul 7, 2022
@sanjarcode
Copy link
Member Author

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.

@sanjarcode
Copy link
Member Author

Closely related, #15

@sanjarcode sanjarcode changed the title Dividing problem into halves for DnC may not always work Dividing problem into "very small halves" for DnC may not always work Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant