data-structures-algorithms-python
data-structures-algorithms-python copied to clipboard
3_odd_even_numbers.py code is not optimised
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)