rsingh
BAN USER
Comments (5)
Reputation 40
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
int printNewArray(int *arr,int size)
{
int *temp = new int(size);
int i;
for(i=0;i<size;i++)
{
temp[i] = 0;
}
for(i=size-1;i>=0;i--)
{
int j = size-1;
while(j>i)
{
if(arr[j]>arr[i])
{
temp[i] = temp[i]+1;
}
j--;
}
}
for(i=0;i<size;i++)
{
cout<<temp[i]<<" ";
}
cout<<endl;
return 0;
}
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
This problem we solve o(n) time complexity and o(1) space complexity but if anyone has better solution so please share thier solution.
printNum()
{
int arr[]={2,3,1,4,3,2};
int size=sizeof(arr)/sizeof(arr[0]);
for(i=0;i<size;i++)
{
mul = mul*arr[i];
}
for(i=0;i<size;i++)
{
printf("%d\n",mul/arr[i]);
}
}
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
1st Simple solution is:
- rsingh December 01, 2016