vicky
BAN USER- 0of 0 votes
AnswersThe 2020 is a number where index value is equal to number of times occurrence of index in number. for eg: for 2020
- vicky
index(0)=2 (as 0 occured 2 times in 2020)
index(1)=0 (as 1 occured 0 times)
index(2)=2 (as 2 occured 2 times)
index(3)=0 (as 3 occured 0 times)
Now input given is a number, determine whether the given number posses property same as 2020 (given as example in above question)| Report Duplicate | Flag | PURGE
Global Scholar Developer Program Engineer
@jigar @geeks
u both coded it correctly. Let me make it more readable.
this code gives u the soln in O(n) complexity
void merge(int a[],int b[], int M)
{
int i=M-1,j=M-1,k=M+M-1;
while(i>=0 && j>=0)
{
if(a[i]>b[i])
a[k--]=a[i--];
while(a[i]<=b[i])
{
a[k--]=b[j--];
if(j<0)
break;
}
}
}
cheers
void reverse(char a[],int start,int end)
{
char temp;
int i;
int l=(start+ceil((end-start)/2));
for(i=start;i<=l;i++)
{
temp=a[i];
a[i]=a[end];
a[end]=temp;
end--;
}
in main function
int main()
{
reverse(a,0,l-1);
int i;
for(i=0;i<=l-1;i++)
{
if(a[i]==32)
{
reverse(a,start,i-1);
start=i+1;
}
}
reverse(a,start,l-1);
}
Repsamuelcsmith700, Accountant at Absolute Softech Ltd
Je suis chef d'équipe de support Office dans une entreprise Action Auto. Je suis également rédacteur de blog. J ...
Repjacksonbetty625, Accountant at 247quickbookshelp
My work is specialized help, regardless of whether on the telephone, face to face, or distantly, identified with PC frameworks ...
Repanneabush, AT&T Customer service email at Accolite software
Hello, I am Anne and I live in Tampa, USA. I am working in a company as a caretaker. I ...
Repcarmelalewis9, Area Sales Manager at AMD
I am fond of reading stories then reading articles which are all about a story of a beautiful nature and ...
int print(int x)
- vicky September 18, 2011{
if(x==0)
return 0;
print(x/10);
if(x/10!=0)
printf(",%d",x%10);
else
printf("%d",x%10);
}