Skip to content
Open
Changes from 3 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
46 changes: 46 additions & 0 deletions src/incrementaltest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
def two_sum(nums, target):
seen = {}

for i, num in enumerate(nums):
complement = target - num

if complement in seen:
return [seen[complement], i]

seen[num] = num
Comment thread
mchun2288 marked this conversation as resolved.

return []


class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next


def reverse_linked_list(head):
prev = None
current = head

while current:
next_node = current.next
current.next = prev
prev = current
current = next_node

return current


def is_valid_parentheses(s):
stack = []
mapping = {')': '(', '}': '{', ']': '['}

for char in s:
if char in mapping:
top = stack.pop() if stack else '#'
if mapping[char] != top:
return False
else:
stack.append(char)

return True
Comment thread
mchun2288 marked this conversation as resolved.
Outdated
Loading