From 17b275db6112cc2a55d2ea98fb3b9038c22cae14 Mon Sep 17 00:00:00 2001 From: SushmitaY <30928963+SushmitaY@users.noreply.github.com> Date: Tue, 24 Oct 2017 22:01:42 +0530 Subject: [PATCH] Update maxindex.py In line 12, change the condition from lst[i] >= lst[i+1] -> lst[i] > lst[i+1]. You can save the time spent on swapping elements when they are equal. --- maxindex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maxindex.py b/maxindex.py index 3a9f86e..b5827fa 100644 --- a/maxindex.py +++ b/maxindex.py @@ -9,7 +9,7 @@ def maxAtIndex(lst, index, i=0): if i == index: return - if lst[i] >= lst[i+1]: + if lst[i] > lst[i+1]: lst[i], lst[i+1] = lst[i+1], lst[i] return maxAtIndex(lst, index, i+1)