Skip to content

Instantly share code, notes, and snippets.

View wanderindev's full-sized avatar

Javier Feliu wanderindev

View GitHub Profile
class TreeNode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def invert_tree(self, root):
"""
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution(object):
def reverse_list(self, head):
"""
:type head: ListNode
from collections import deque
class MinStack(object):
def __init__(self):
self.items = deque()
def is_empty(self):
return not self.items
from collections import deque
class TreeNode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution(object):
def merge_two_lists(self, list1, list2):
"""
:type list1: Optional[ListNode]
class Solution(object):
def max_profit(self, prices):
"""
:type prices: List[int]
:rtype: int
"""
left_index = 0
right_index = 1
max_profit = 0
class Solution(object):
def max_area(self, height):
"""
:type height: List[int]
:rtype: int
"""
max_volume = 0
left_pointer = 0
right_pointer = len(height) - 1
def two_sum(self, nums, i, results):
left_pointer = i + 1
right_pointer = len(nums) - 1
while left_pointer < right_pointer:
total = nums[i] + nums[left_pointer] + nums[right_pointer]
if total > 0:
right_pointer -= 1
elif total < 0:
left_pointer += 1
class Solution:
def two_sum(self, numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""
left_pointer = 0
right_pointer = len(numbers) - 1
class Solution:
def is_alpha_num(self, c):
return (
ord("A") <= ord(c) <= ord("Z")
or ord("a") <= ord(c) <= ord("z")
or ord("0") <= ord(c) <= ord("9")
)
def is_palindrome(self, s):
"""