Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
little recursion solution in Clear category for Greedy Number by rybld2
def greedy_number(line: str, length: int) -> str:
if len(line) == length: return line
if not length : return ""
possibles = {int(l) for l in line[0:len(line) - length + 1]}
maxi = str(max(possibles))
return maxi+greedy_number(line[line.index(maxi)+1:], length -1)
Nov. 6, 2021
Comments: