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
11 changes: 11 additions & 0 deletions maximum-depth-of-binary-tree/doh6077.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# Time: O(n)
# Maximum Depth of Binary Tree
class Solution:
def maxDepth(self, root: Optional[TreeNode]) -> int:
if not root:
return 0 # base case
left = self.maxDepth(root.left)
right = self.maxDepth(root.right)

return 1 + max(left, right)
17 changes: 17 additions & 0 deletions merge-two-sorted-lists/doh6077.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# 21. Merge Two Sorted Lists

class Solution:
def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
tempNode = ListNode()
node = tempNode
while list1 and list2:
if list1.val < list2.val:
node.next = list1
list1 = list1.next
else:
node.next = list2
list2 = list2.next
node = node.next
node.next = list1 or list2
return tempNode.next