Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sanibalakrishna authored Jun 27, 2021
1 parent 1cba9da commit d472a09
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
24 changes: 24 additions & 0 deletions problem_1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<bits/stdc++.h>
using namespace std;
void RemoveconsDuplicates(char* String)
{
if(String[0] == '\0')
return;
if(String[0] == String[1])
{
int i =0;
while(String[i] != '\0'){
String[i] = String[i + 1];
i++;
}
RemoveconsDuplicates(String);

}
RemoveconsDuplicates(String + 1);
}
int main(){
char String[]="aabcca";
RemoveconsDuplicates(String);
cout<<String<< endl;
return 0;
}
28 changes: 28 additions & 0 deletions problem_2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<bits\stdc++.h>
using namespace std;

int SubArrayMaxSum(int arr[], int size)
{
int maxfar = INT_MIN, maxendinghere = 0;

for (int i = 0; i < size; i++)
{
maxendinghere = maxendinghere + arr[i];
if (maxfar < maxendinghere)
maxfar = maxendinghere;

if (maxendinghere < 0)
maxendinghere = 0;
}
return maxfar;
}


int main()
{ int N = 5;
int arr[] = {1,2,3,-2,5};

int maxsum = SubArrayMaxSum(arr, N);
cout << maxsum<<endl;
return 0;
}
37 changes: 37 additions & 0 deletions problem_3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include<bits\stdc++.h>
using namespace std;
int RemoveDuplicates(int arr[], int n)
{

if (n==0 || n==1)
return n;

int temp[n];


int j = 0;
for (int i=0; i<n-1; i++)

if (arr[i] != arr[i+1])
temp[j++] = arr[i];


temp[j++] = arr[n-1];


for (int i=0; i<j; i++)
arr[i] = temp[i];

return j;
}


int main()
{ int N = 5 ;
int arr[] = {2,2,2,2,2};
N = RemoveDuplicates(arr, N);
for (int i=0; i<N; i++)
cout << arr[i] << " ";

return 0;
}

0 comments on commit d472a09

Please sign in to comment.