Skip to content

Bug Fixed : Array Pair Sum Divisibility Problem GFG#59

Open
Shiv13jm wants to merge 1 commit intoMAZHARMIK:masterfrom
Shiv13jm:patch-1
Open

Bug Fixed : Array Pair Sum Divisibility Problem GFG#59
Shiv13jm wants to merge 1 commit intoMAZHARMIK:masterfrom
Shiv13jm:patch-1

Conversation

@Shiv13jm
Copy link
Copy Markdown

@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