Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
leetcode: finished #915
Browse files Browse the repository at this point in the history
  • Loading branch information
xqm32 committed Jan 6, 2024
1 parent d6c2c7e commit abedbe2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions content/leetcode/2024/1.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ title: 2024.1
draft: false
---

# 2024.1.6

```python
#
# @lc app=leetcode.cn id=915 lang=python3
#
# [915] 分割数组
#

# @lc code=start
from typing import List


class Solution:
def partitionDisjoint(self, nums: List[int]) -> int:
n = len(nums)
max_left = [0] * n
min_right = [0] * n
max_left[0] = nums[0]
min_right[-1] = nums[-1]
for i in range(1, n):
max_left[i] = max(max_left[i - 1], nums[i])
for i in range(n - 2, -1, -1):
min_right[i] = min(min_right[i + 1], nums[i])
for i in range(1, n):
if max_left[i - 1] <= min_right[i]:
return i


# @lc code=end
```

# 2024.1.5

```python
Expand Down

0 comments on commit abedbe2

Please sign in to comment.