Add new course

This commit is contained in:
AndrewTrieu
2023-01-08 18:43:01 +02:00
parent 75313f3f05
commit 6f5c7f67b4
49 changed files with 835669 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
def split(T):
count = 0
max_from_left = T[0]
min_to_right = T[-1]
for i in range(1, len(T)):
max_from_left = max(max_from_left, T[i])
for i in range(len(T) - 2, -1, -1):
min_to_right = min(min_to_right, T[i])
for i in range(len(T) - 1):
if max_from_left < min_to_right:
count += 1
max_from_left = max(max_from_left, T[i])
min_to_right = min(min_to_right, T[i+1])
return count
if __name__ == "__main__":
print(split([1, 2, 3, 4, 5])) # 4
print(split([5, 4, 3, 2, 1])) # 0
print(split([2, 1, 2, 5, 7, 6, 9])) # 3
print(split([1, 2, 3, 1])) # 0