a...@pythoncraft.com (Aahz) writes:

> In article <4b7a91b1.6030...@lonetwin.net>, steve  <st...@lonetwin.net> wrote:
>>On 02/16/2010 05:49 PM, W. eWatson wrote:
>>>
>>> See Subject. a = [1,4,9,3]. Find max, 9, then index to it, 2.
>>
>>The most obvious would be a.index(max(a)). Is that what you wanted ?
>
> The disadvantage of that is that it's O(2N) instead of O(N).

:-)

Joke aside, even though you traverse the list twice, it may still be
quicker than other solutions because both max and list.index are C
functions and no intermediate object is constructed.

-- 
Arnaud
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to