Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import List

class Solution:
def maxArea(self, height: List[int]) -> int:
left = 0
right = len(height) - 1
max_area = 0

while left < right:
# Calculate current area
width = right - left
current_height = min(height[left], height[right])
current_area = width * current_height
max_area = max(max_area, current_area)

# Move pointer with shorter height
if height[left] < height[right]:
left += 1
else:
right -= 1

return max_area
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from typing import List

class Solution:
def subarraySum(self, nums: List[int], k: int) -> int:

answer = 0
dp = {0:1}
acc = 0

for num in nums:
acc += num
answer += dp.get(acc - k, 0)
dp[acc] = dp.get(acc, 0) + 1

return answer
Loading