Skip to content

Commit

Permalink
Final solution
Browse files Browse the repository at this point in the history
  • Loading branch information
sudheerdagar committed Oct 8, 2022
1 parent 7248f92 commit 253ae57
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
2 changes: 1 addition & 1 deletion C++/Arithmetic Number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using namespace std;

int inSequence(int a, int b, int c)
{
if (c == 0)
if (c == 0 )
{
if (a != b)
{
Expand Down
27 changes: 27 additions & 0 deletions C++/Single Number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<bits/stdc++.h>
using namespace std;
#define lld long long int


int singlenumber(int arr[],int n)
{
int ans=0;//we will use the xor property stating that xors of 2 same numbers is 0
for(int i=0;i<n;i++)
{
ans=ans^arr[i];
}
return ans;





}




int main()
{
return 0;
}
61 changes: 61 additions & 0 deletions C++/Sort an array of 0s, 1s and 2s.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include<bits/stdc++.h>
using namespace std;
#define lld long long int

void sort012(int arr[],int n)
{
int temp[3]={0};//we will apply count sort so its the storing array

//traversing over the array and will increase the suitable index value
for(int i=0;i<n;i++)
{
if(arr[i]==1)
{
temp[1]++;
}
else if(arr[i]==0)
{
temp[0]++;
}
else
{
temp[2]++;
}
}
int i=0;
while(arr[0]>0&&i<n)
{
arr[i]=0;
arr[0]--;
i++;
}

while(arr[1]>0&&i<n)
{
arr[i]=1;
arr[1]--;
i++;
}

while(arr[2]>0&&i<n)
{
arr[i]=2;
arr[2]--;
i++;
}






}





int main()
{
return 0;
}

0 comments on commit 253ae57

Please sign in to comment.