Last active
March 30, 2023 03:56
-
-
Save aLucaz/0a5764c26cfd6bce21c496e9a88fa7a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(arr): | |
i = 0 | |
j = len(arr) - 1 | |
while i <= j: | |
if (arr[i] % 2) != 0: | |
n = arr.pop(i) | |
arr.insert(len(arr), n) | |
else: | |
n = arr.pop(i) | |
arr.insert(0, n) | |
i+=1 | |
if (arr[j] % 2) != 0: | |
n = arr.pop(j) | |
arr.insert(len(arr), n) | |
else: | |
n = arr.pop(j) | |
arr.insert(0, n) | |
j-=1 | |
print(arr) | |
return arr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment