You are viewing a single comment's thread. Return to all comments →
def biggerIsGreater(w): i = -2 try: while w[i] >= w[i + 1]: i -= 1 except IndexError: return "no answer" str1 = w[:i] str2 = list(w[i:]) str2.sort() loc = str2.index(w[i]) while str2[loc] <= w[i]: loc += 1 str1 += str2[loc] str2.pop(loc) return str1 + "".join(str2)
Seems like cookies are disabled on this browser, please enable them to open this website
Bigger is Greater
You are viewing a single comment's thread. Return to all comments →