Water
BAN USER- 1of 1 vote
AnswersFind the merging point of 2 given link lists...
- Water in United States
I gave him the best O(n) solution i.e by first finding the length of both link list ..........
But he said that he doesn't want an efficient soln. but a soln which is original and cannot be found in any book or over the internet| Report Duplicate | Flag | PURGE
NetApp C
I think this could work if there is a restriction on size of input............
For Ex, if the input is assumed to be only 4 digit long.....Then your method can be modified by now using 2 bit instead of 1 bit for each digit....
2207
(00)(00)(01)(00)(00)(00)(00)(10)(00)(01)
#include <stdio.h>
int findCount(int n,int k)
{
int count=0,sum=0;
int i=1;
int sumk=k*(k-1)/2;
while(i <= n/2)
{
sum=(i*k)+sumk;
if(sum < n)
{
if(n-sum+(i+k-1)<n)
count=count+k;
}
else
break;
i++;
}
return count;
}
int main()
{
int n,k;
scanf("%d",&n);
scanf("%d",&k);
int count=findCount(n,k);
printf("Count = %d\n",count);
return 0;
}
Repsylviarashtons, Accountant at ASAPInfosystemsPvtLtd
I am a journalist. Outside the office, I enjoy additional writing time in a different genre of historical fiction. I ...
Repdianamowery95, Consultant at Delve Networks
My Name is Diana Mowery. I am from St. Louis and received a Bachelor Degree and My Masters Degree from ...
Repshirleygause93, Analyst at Absolute Softech Ltd
Hi, I am Shirley from taxes, Conducted a re-profiling project which enabled our customers to receive orders more efficiently.Planning ...
Thats what I told him.......He said this is the most general solution.
- Water September 18, 2012