Skip to content

Commit

Permalink
Merge pull request #77 from abhishek-217/main
Browse files Browse the repository at this point in the history
Solution of day 1 question on leetcode in cpp
  • Loading branch information
arya2004 authored Oct 14, 2024
2 parents f810623 + 7cedd45 commit 43eeead
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions solutions/day01/solution_cpp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Solution {
public:
bool canArrange(vector<int>& arr, int k) {
int n = arr.size();

vector<int>result(k,0);

for(int i=0 ; i<n; i++){
int rem = ((arr[i] % k) + k) % k;

result[rem]++;
}

if(result[0] % 2 != 0) return false;

for(int i = 1; i<= k/2 ; i++){
if(result[i] != result[k-i]){
return false;
}
}

return true;;
}
};
Empty file.

0 comments on commit 43eeead

Please sign in to comment.