Skip to content

Commit

Permalink
Merge pull request #80 from LeViiAcKerMan01/levii
Browse files Browse the repository at this point in the history
Added POTD for 14 July.
  • Loading branch information
Ayu-hack authored Oct 10, 2024
2 parents 20924f4 + 2439350 commit d31dccb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions July 2024/Segregate_0s_and_1s(14 July).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Solution {
public:
void segregate0and1(vector<int> &arr) {

map<int, int> mp;

for(int i = 0; i < arr.size(); i++){

mp[arr[i]]++;
}

arr.clear();

while(mp[0] != 0){

arr.push_back(0);
mp[0]--;
}
while(mp[1] != 0){

arr.push_back(1);
mp[1]--;
}
// code here
}
};

0 comments on commit d31dccb

Please sign in to comment.