suppose sorted array is

1,2,3,5,10,12,13,17,19,25

so if u want to find possible combinations, with 25 as hypotenuse, then only
range 10 ... 19 could have answer

as 19 + 10 > 25

On Fri, Oct 14, 2011 at 3:14 PM, Ankur Garg <[email protected]> wrote:

> @Rahul
>
> Pls elaborate with an example ...
>
>
> On Fri, Oct 14, 2011 at 2:35 PM, rahul patil <
> [email protected]> wrote:
>
>> You can take advantage of a basic property of triagle that
>>
>> sum of largest side of triangle < sum of other two sides,
>>
>> After sorting you could easily deside the range in which possible solution
>> could be found for a chosen hypotenuse
>>
>> On Fri, Oct 14, 2011 at 11:10 AM, ravindra patel <
>> [email protected]> wrote:
>>
>>> @Wladimir, yeah I have heard about that. Another way of populating
>>> primitive pythagoreans is, for any natural number m > 1  (m^2 - 1, 2m, m^2 +
>>> 1) forms a pythagorean triplet. This is useful in populating pythagorean
>>> tiplets but here the problem is to search such triplets from a given int
>>> array.
>>>
>>> @ rahul, Hash of z^2 - x^2 for each pair of z,x itself will of the size
>>> n*(n-1). I am not sure how it will work in O(n) time then.
>>>
>>> Thanks,
>>> - Ravindra
>>>
>>>
>>> On Fri, Oct 14, 2011 at 12:25 AM, Ankur Garg <[email protected]>wrote:
>>>
>>>> @rahul...How do u choose z and x for computing z^2 -x^2 ?
>>>>
>>>> On Thu, Oct 13, 2011 at 11:34 PM, rahul <[email protected]> wrote:
>>>>
>>>>> You can create a hash with sqrt(z2-x2). This will make it o(n). The
>>>>> interviewer just made it lil tricky. That's all
>>>>>
>>>>> --
>>>>> 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/-/2Ge2pjt4N-4J.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> 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 [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> 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 [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Regards,
>> Rahul Patil
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards,
Rahul Patil

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to