Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions missingNumberInArray.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*find the smallest positive number missing from the array*/

#include<iostream>
using namespace std;
typedef long int li;
typedef long long int ll;
int main()
{

li n;
cin>>n;
ll a[n],max=0;
for(li i=0;i<n;i++){
cin>>a[i];
if(a[i]>max){
max=a[i];
}
}
ll b[max+1]={0};
for(ll i=0;i<n;i++){
if(a[i]>0){
b[a[i]]++;
}
}
int c=0;
for(ll i=1;i<max;i++){
if(b[i]<1){
cout<<i<<"\n";
c++;
break;
}
}
if(c==0){
cout<<max+1<<"\n";
}

return 0;
}
30 changes: 30 additions & 0 deletions powerNumber.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*Following is the c++ code to calculate N raised to R, where N is number and R is reverse of N*/

#include<cmath>
#include<iostream>
using namespace std;
const long long M = 1e9+7;
long long int p(long long int n,long long int r){
if(!r)
return 1;
long long int t = p(n, r/2);
if(r%2==1)
return (n * ((t*t)%M)) %M;
return (t*t)%M;
}

int main() {

long int N=12,sum=0;
int l=log10(N);
long int x=N;
for(int i;x>0;i++){
long int temp=0;
temp=x%10;
x=x/10;
sum=sum+temp*pow(10,l--);
}
cout<<p(N,sum)<<"\n";

return 0;
}