gowthamganguri
BAN USER- 6of 6 votes
AnswersGiven an input array
- gowthamganguri in India
a={1,2,3,6,2,8----}
product of all numbers=p=a[0]*a[1]*---a[n-1] where n is size of array
output arrau should be b={p/a[0],p/a[1],p/a[2]-----}. you should not use division operator.Time complexity should be less than o(n2).| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays
sorry product is 576
- gowthamganguri August 29, 2013how we find first and last numbers.
- gowthamganguri August 13, 2013numbers are not separated by any special character. we have to find whether they are 1digit,2digit or 3digit numbers
- gowthamganguri August 13, 2013Using Bfs
void oddeven(Bnode root)
{
Bnode cur=root;
Queue<Bnode> q= new LinkedList();
q.add(cur);
int curlevel=1,nxtlevel=0,odd=0,even=0,flag=0;
while(!q.isEmpty())
{
cur=q.poll();
curlevel--;
if(flag==0)
even+=cur.data;
else
odd+=cur.data;
if(cur.left!=null)
{
q.add(cur.left);
nxtlevel++;
}
if(cur.right!=null)
{
q.add(cur.right);
nxtlevel++;
}
if(curlevel==0)
{
curlevel=nxtlevel;
nxtlevel=0;
flag=flag==0?1:0;
}
}
System.out.println("odd-even "+(odd-even));
}
- gowthamganguri June 15, 2013
Repcarleywcote, Problem Setter at Baidu
I am a Photographer in Dallas. I Capture images as directed, taking all aspects into consideration, including outside lighting, shadows ...
RepI am Frank, 29 year old. I have worked with numerous branches, including payroll and human resources, which allows me ...
RepI believe in magic, power, aliens, parallel universe, god. I always dream about the powers and out of the world ...
sorry product is 576
- gowthamganguri August 29, 2013