Skip to content

Instantly share code, notes, and snippets.

View Shakaloid's full-sized avatar

Shakaloid Shakaloid

View GitHub Profile
def split_arrays(arr):
if not arr:
return [], []
mid = len(arr) // 2
return arr[:mid], arr[mid:]
print(split_arrays([1, 2, 3, 4, 5, 6]))
print(split_arrays([1, 2, 3, 4, 5]))
def is_sorted(arr):
for i in range(len(arr) - 1):
if arr[i] > arr[i + 1]:
return False
return True
print(is_sorted([1, 2, 3, 4, 5]))
print(is_sorted([1, 3, 2, 4, 5]))