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,16 @@
class Solution:
def getLastMoment(self, n: int, left: list[int], right: list[int]) -> int:
ants = [[i, -1] for i in left] + [[i, 1] for i in right] # 왼쪽은 -1, 오른쪽은 1
time = 0
live = []

for i in ants:
x, y = i[0], i[1]

if x == 0 and y == -1: # 0에서 왼쪽 방향이면 떨어짐
continue
if x == n and y == 1:
continue
live.append(i)
ants = live

20 changes: 20 additions & 0 deletions leetcode3/송주혜/1695. Maximum Erasure Value
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution:
def maximumUniqueSubarray(self, nums: list[int]) -> int:
numbers = set()
total = 0
answer = 0
rm = 0

for i in range(len(nums)):

while nums[i] in numbers:
numbers.remove(nums[rm])
total -= nums[rm]
rm += 1

# numbers에 없으면 추가
numbers.add(nums[i])
total += nums[i]
answer = max(answer, total)

return answer