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

[ISSUE] - Non-Divisible Subset Problem (HackerRank) #199

Open
BheruSinghPanwar opened this issue Oct 6, 2023 · 1 comment
Open

[ISSUE] - Non-Divisible Subset Problem (HackerRank) #199

BheruSinghPanwar opened this issue Oct 6, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest hacktoberfest contributions

Comments

@BheruSinghPanwar
Copy link

Description

This issue is opened to propose the addition of a HackerRank problem along with its solution to the repository.

DSA Problem

Given a set of distinct integers, print the size of a maximal subset of S where the sum of any 2 numbers in S' is not evenly divisible by k.

Example
S = [19, 10, 12, 10, 24, 25, 22] k = 4

One of the arrays that can be created is S' [0] = [10, 12, 25]. Another is S'[1] = [19, 22, 24]. After testing all permutations, the maximum length solution array has 3 elements.

Function Description
Complete the nonDivisibleSubset function in the editor below.
nonDivisibleSubset has the following parameter(s):

  1. int S[n]: an array of integers
  2. int k: the divisor

Returns
int: the length of the longest subset of S meeting the criteria

Input Format
The first line contains 2 space-separated integers, n and k, the number of values in S and the non factor.
The second line contains n space-separated integers, each an S[i], the unique values of the set

Constraints
1 <= n <= 10 ^ 5
1 <= k <= 100
1 <= S[i] <= 10 ^ 9

All of the given numbers are distinct.

@BheruSinghPanwar BheruSinghPanwar added enhancement New feature or request good first issue Good for newcomers hacktoberfest hacktoberfest contributions labels Oct 6, 2023
@BheruSinghPanwar
Copy link
Author

@iamdestinychild please assign me this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest hacktoberfest contributions
Projects
None yet
Development

No branches or pull requests

1 participant