Skip to content

Instantly share code, notes, and snippets.

View cashlo's full-sized avatar

Cash TingHin Lo cashlo

  • Indeed.com
  • Tokyo
View GitHub Profile
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from ..Script import Script
from UM.Application import Application #To get the current printer's settings.
from UM.Logger import Logger
class PauseAtTopAndBottom(Script):
def __init__(self):
class Solution(object):
def findLadders(self, beginWord, endWord, wordList):
"""
:type beginWord: str
:type endWord: str
:type wordList: List[str]
:rtype: List[List[str]]
"""
connection = {w: set() for w in wordList}
class Solution(object):
def numDistinctIslands(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
def get_island(oi, oj, grid):
lands = []
def dfs(i, j, grid):
if i < 0 or j < 0: return
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def constructMaximumBinaryTree(self, nums):
"""
class Solution(object):
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
def search( tl, br ):
print 'Searching...'
class Solution(object):
def shortestPalindrome(self, s):
"""
:type s: str
:rtype: str
"""
def non_palindrome_index(s):
i = 0
class Solution(object):
def largestDivisibleSubset(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
if not nums: return []
from_big_nums = sorted(nums)
dp = []
for i,n in enumerate(from_big_nums):
class Solution(object):
def findContestMatch(self, n):
"""
:type n: int
:rtype: str
"""
def wrap_thing(a, b):
return '({},{})'.format(a,b)
to_wrap = [i for i in range(1,n+1)]
while len(to_wrap) > 1:
class Trie(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.char_map = {}
def insert(self, word):
"""
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def lowestCommonAncestor(self, root, p, q):
"""