1
I was trying to solve this issue in URI and I managed to reach the output required by URI. However I got the error Time limit exceeded
, because the running time limit is 2s, and my code resulted in 3s. I would like you to help me optimize my code to not exceed this limit.
Question link in URI and enunciation image:
https://www.urionlinejudge.com.br/judge/pt/problems/view/1146
My code:
N = 1
sequencia = ''
while N != 0:
N = int(input())
i = 1
while i <= N:
sequencia = sequencia + f'{i} '
i = i + 1
else:
sequencia = sequencia[:-1] + '\n'
print(sequencia[:-1])