thanks i got it...

On Thu, Jul 14, 2011 at 9:13 AM, surender sanke <surend...@gmail.com> wrote:

> space o(2n)
>
> int LSM()
> {
>     int a[] = {2,-8,-3,1,2};
>     int b[50],b1[50];
>     int n = sizeof(a)/sizeof(a[0]);
>     int i=0;
>     b[0]=a[0];
>     for(i=1;i<n;i++)
>
>     {
>         if(b[i-1]==0)
>             b[i]=a[i];
>
>         else
>             b[i]*=a[i];
>     }
>
>     b1[n-1] = a[n-1];
>     for(i=n-2;i>=0;i--)
>     {
>         if(b1[i+1]==0)
>             b1[i]=a[i];
>         else
>             b1[i]*=a[i];
>     }
>
>     int m=INT_MIN;
>     for(i=0;i<n;i++)
>         m = ( (b[i]>b1[i])?(b[i]>m?b[i]:m):(b1[i]>m?b1[i]:m) );
>     return m;
> }
>
> surender
>
> On Thu, Jul 14, 2011 at 8:17 AM, Aakash Johari <aakashj....@gmail.com>wrote:
>
>> typo: for Min[i] change max(...) to min(...)
>>
>>
>>
>> On Tue, Jul 12, 2011 at 11:09 PM, Neeraj Gupta <
>> neeraj.gu...@nsitonline.in> wrote:
>>
>>> Oppalis algo-
>>> Please let me know if there is a bug in it.
>>> http://www.ideone.com/u1m07
>>>
>>> On Wed, Jul 13, 2011 at 11:36 AM, Aniket Dutta 
>>> <aniketdutt...@gmail.com>wrote:
>>>
>>>> @sunny: right thanks for correcting
>>>>
>>>>
>>>> On Wed, Jul 13, 2011 at 11:33 AM, sunny agrawal <
>>>> sunny816.i...@gmail.com> wrote:
>>>>
>>>>> @Aniket Dutta
>>>>> Solution for your case will be 96
>>>>>
>>>>> Algorithm Posted by Oppilas will do and is O(n).
>>>>>
>>>>>
>>>>> On Wed, Jul 13, 2011 at 11:28 AM, Aniket Dutta <
>>>>> aniketdutt...@gmail.com> wrote:
>>>>>
>>>>>> @vaibhav: Sir ur algo fails in this array {2,-8,-3,1,2} it should give
>>>>>> answer as 24 but ur algo gives 2
>>>>>>
>>>>>>
>>>>>> On Wed, Jul 13, 2011 at 11:02 AM, varun pahwa <
>>>>>> varunpahwa2...@gmail.com> wrote:
>>>>>>
>>>>>>> please ignore my previous post that solution is wrong.
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Jul 13, 2011 at 11:01 AM, sameer.mut...@gmail.com <
>>>>>>> sameer.mut...@gmail.com> wrote:
>>>>>>>
>>>>>>>> @kranthi :
>>>>>>>>
>>>>>>>> d solution u ve given is only for 2 continuous elements..
>>>>>>>> wr as d question doesnt limit it to 2.. It can be d product of any
>>>>>>>> no. of continuous elements.
>>>>>>>> So if the array is 200, 5, -2, -3, -1
>>>>>>>> den ans shd be 200*5*-2*-3 = 6000
>>>>>>>>
>>>>>>>> N if m workin ur algo in d right way, den it ll give 1000
>>>>>>>>
>>>>>>>> On Wed, Jul 13, 2011 at 10:52 AM, kranthi kumar <
>>>>>>>> damarlakran...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> I think this is the solution what u need.... U can do in O(n)
>>>>>>>>> time...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> #include<iostream>
>>>>>>>>>>> using namespace std;
>>>>>>>>>>>
>>>>>>>>>>> main()
>>>>>>>>>>> {
>>>>>>>>>>> int a[7] = { 0, 0, 0, 19, 380, -1, 2};
>>>>>>>>>>> int prod, nprod;
>>>>>>>>>>> bool x = false;
>>>>>>>>>>>
>>>>>>>>>>> for(int i=0;i<6;i++)
>>>>>>>>>>> {
>>>>>>>>>>> nprod = a[i] * a[i+1];
>>>>>>>>>>> cout<<nprod<<endl;
>>>>>>>>>>> if( x == false)
>>>>>>>>>>> {
>>>>>>>>>>> x = true;
>>>>>>>>>>> prod = nprod;
>>>>>>>>>>> }
>>>>>>>>>>> else if( x== true && prod < nprod )
>>>>>>>>>>> prod = nprod;
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> cout<<"\nResult: "<<prod;
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Regards:
>>>>>>>>> -----------------------
>>>>>>>>> D Kranthi kumar
>>>>>>>>> Computer Science & Engg.
>>>>>>>>> 1st Mtech, IIT Madras.
>>>>>>>>>
>>>>>>>>>  --
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "Algorithm Geeks" group.
>>>>>>>>> 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.
>>>>>>>>>
>>>>>>>>
>>>>>>>>  --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "Algorithm Geeks" group.
>>>>>>>> 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.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Varun Pahwa
>>>>>>> B.Tech (IT)
>>>>>>> 7th Sem.
>>>>>>> Indian Institute of Information Technology Allahabad.
>>>>>>> Ph : 09793899112
>>>>>>> Official Email :: rit2008...@iiita.ac.in
>>>>>>> Another Email :: varunpahwa.ii...@gmail.com
>>>>>>>
>>>>>>> People who fail to plan are those who plan to fail.
>>>>>>>
>>>>>>>  --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Algorithm Geeks" group.
>>>>>>> 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.
>>>>>>>
>>>>>>
>>>>>>  --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> 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.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sunny Aggrawal
>>>>> B-Tech IV year,CSI
>>>>> Indian Institute Of Technology,Roorkee
>>>>>
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> 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.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> 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.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> 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.
>>>
>>
>>
>>
>> --
>> -Aakash Johari
>> (IIIT Allahabad)
>>
>>
>>
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> 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.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> 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.
>



-- 
shilpa gupta
b tech 2nd year
computer science and engineering
mnnit allahabad

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
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