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

Bug Fixed : Array Pair Sum Divisibility Problem GFG #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Shiv13jm
Copy link

@Shiv13jm Shiv13jm commented Oct 1, 2024

The current implementation of the canPair function uses an unordered set to track remainders. However, this approach has a significant flaw: sets store only unique values and do not account for multiple occurrences of the same remainder. This leads to incorrect results in certain cases.

Example

Consider the following example:

  • k = 6
  • nums = [10, 4, 2, 2]

Issue

In the example above, the remainders are:

10 % 6 = 4
4 % 6 = 4
2 % 6 = 2
2 % 6 = 2
The set will store only unique values, so it will not correctly handle the multiple occurrences of the remainder . This results in an incorrect outcome.

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

Successfully merging this pull request may close these issues.

1 participant