Merge two sorted lists into a single sorted list. :param left: Left collection :param right: Right collection :return: Merged result
(left: list, right: list)
| 30 | """ |
| 31 | |
| 32 | def merge(left: list, right: list) -> list: |
| 33 | """ |
| 34 | Merge two sorted lists into a single sorted list. |
| 35 | |
| 36 | :param left: Left collection |
| 37 | :param right: Right collection |
| 38 | :return: Merged result |
| 39 | """ |
| 40 | result = [] |
| 41 | while left and right: |
| 42 | result.append(left.pop(0) if left[0] <= right[0] else right.pop(0)) |
| 43 | result.extend(left) |
| 44 | result.extend(right) |
| 45 | return result |
| 46 | |
| 47 | if len(collection) <= 1: |
| 48 | return collection |
no test coverage detected