Skip to content

Instantly share code, notes, and snippets.

View yesidays's full-sized avatar
🎯
Focusing

Yesi yesidays

🎯
Focusing
View GitHub Profile
@yesidays
yesidays / last-stone-weight.py
Created April 12, 2020 18:05
Last Stone Weight
#https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/529/week-2/3297/
class Solution(object):
def lastStoneWeight(self, stones):
"""
:type stones: List[int]
:rtype: int
"""
while len(stones) > 1:
stones.sort()
new_value = stones.pop() - stones.pop()
@yesidays
yesidays / backspace-string-compare.py
Last active April 10, 2020 16:23
Backspace String Compare
class Solution(object):
def backspaceCompare(self, S, T):
"""
:type S: str
:type T: str
:rtype: bool
"""
def deleteBackspace(word):
temporal = []
@yesidays
yesidays / middle-linked.py
Created April 9, 2020 00:07
Middle of the Linked List
#https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/529/week-2/3290/
class Solution(object):
def middleNode(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
middle = head
@yesidays
yesidays / counting-elements.py
Created April 7, 2020 17:39
Couting Elements - Leetcode
class Solution(object):
def countElements(self, arr):
"""
:type arr: List[int]
:rtype: int
"""
result = 0
for j in arr:
@yesidays
yesidays / group-anagrams.py
Created April 7, 2020 00:28
Group anagrams - Leetcode
#https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/528/week-1/3288/
class Solution(object):
def groupAnagrams(self, strs):
"""
:type strs: List[str]
:rtype: List[List[str]]
"""
keys = {}
result = []
@yesidays
yesidays / move_zeroes.py
Created April 5, 2020 02:12
Move zeroes - Leetcode
class Solution(object):
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: None Do not return anything, modify nums in-place instead.
"""
count = 0
for i, num in enumerate(nums):
if num == 0:
@yesidays
yesidays / maximum_subarray.py
Created April 4, 2020 01:16
Maximum Subarray - Leetcode
# https://leetcode.com/explore/featured/card/30-day-leetcoding-challenge/528/week-1/3285/
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
maximum = nums[0]
current = 0
for i in range(len(nums)):
@yesidays
yesidays / happy_number.py
Created April 3, 2020 03:38
Happy Number - Leetcode
#https://leetcode.com/explore/featured/card/30-day-leetcoding-challenge/528/week-1/3284/
class Solution(object):
def isHappy(self, n):
"""
:type n: int
:rtype: bool
"""
exists = set()
while n != 1:
@yesidays
yesidays / single_number.py
Created April 1, 2020 18:11
Leetcode - Single number solution
#https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/528/week-1/3283/
class Solution:
def singleNumber(self, nums: List[int]) -> int:
nums.sort()
found = 0
for i in nums:
if nums.count(i) == 1:
found = i
return found

Docker commands

ID of the container

docker ps

Inspect containers

docker inspect [container-id]

Docker Images

docker images