F
F
fronttrty2020-06-18 12:06:02
Python
fronttrty, 2020-06-18 12:06:02

How to speed up the code?

b = list(map(int,input().split()))
d = []
j = 0
x = 0
for i in range(len(b)) :
    x = 0
    for j in range(len(d)):
        if b[i] >= d[j]:
            x += 1 
        elif x > 0:
            break
        else:
            j = 0
            break
    d = d[x:]
    d.append(b[i])
    d.sort()
    print(len(d))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
szafranji, 2020-06-18
@szafranji

Read the book "Clean code" and then the code will definitely work faster)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question