data-structures-algorithms-python icon indicating copy to clipboard operation
data-structures-algorithms-python copied to clipboard

3_odd_even_numbers.py code is not optimised

Open Aribaskar-jb opened this issue 2 years ago • 0 comments

max = int(input("Enter max number: "))

odd_numbers = []

for i in range(1, max): if i % 2 == 1: odd_numbers.append(i)

print("Odd numbers: ", odd_numbers)

The loop is Executed 0(n) times we can reduce as 0(n/2)

Aribaskar-jb avatar May 16 '23 12:05 Aribaskar-jb