This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def searchMatrix(self, matrix, target): | |
""" | |
:type matrix: List[List[int]] | |
:type target: int | |
:rtype: bool | |
""" | |
def search( tl, br ): | |
print 'Searching...' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def shortestPalindrome(self, s): | |
""" | |
:type s: str | |
:rtype: str | |
""" | |
def non_palindrome_index(s): | |
i = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Trie(object): | |
def __init__(self): | |
""" | |
Initialize your data structure here. | |
""" | |
self.char_map = {} | |
def insert(self, word): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): | |
""" |