@Shady: You can do it with just the input array and the output array. In 
the language of Atul007, put temp2 in the output array, and calculate temp1 
as a scalar, i.e., one element at a time as you replace the elements of 
temp2 with the result.
 
Dave

On Thursday, August 16, 2012 5:40:23 AM UTC-5, shady wrote:

> for n elements, space used - 2n
> can we do better ?
>
> On Thu, Aug 16, 2012 at 3:20 PM, atul anand <atul.8...@gmail.com<javascript:>
> > wrote:
>
>> input :   2    3   4    5
>> temp1 : 2    6   24   120
>> temp2 : 120  60  20   5
>>
>> for given input ..take tow temp array.
>> temp1[i] = input[0] * input[1] * input[2] * input[3]......input[i]
>> temp2[i] = input[i] * input [i + 1] * input[i + 2]....input[n];
>>
>> now out[i] = temp1[i-1] * temp2[i+1];
>>
>>
>> On Thu, Aug 16, 2012 at 2:26 PM, Hariraman R <rphar...@gmail.com<javascript:>
>> > wrote:
>>
>>>
>>> Hi,
>>>
>>>        This is a microsoft question asked in our campus previous year. 
>>> Anyone having idea please share it here...
>>>
>>>
>>>        Given an array of n elements A[n]. Write a program to create a new 
>>> array OUT[n], 
>>>
>>>         which has its elements as multiplication of all the elements in the 
>>> input array A[n] except that element (i.e.) OUT[2] = A[0] * A[1] * A[3] * ? 
>>> * A[n-1]. 
>>>          Constraint is one should not use division operator.
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algo...@googlegroups.com<javascript:>
>>> .
>>> To unsubscribe from this group, send email to 
>>> algogeeks+...@googlegroups.com <javascript:>.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Algorithm Geeks" group.
>> To post to this group, send email to algo...@googlegroups.com<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> algogeeks+...@googlegroups.com <javascript:>.
>> For more options, visit this group at 
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/u9VqcQM6sz0J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to