I hereby claim:
- I am stalk-calvin on github.
- I am stalkcalvin (https://keybase.io/stalkcalvin) on keybase.
- I have a public key whose fingerprint is A6DB 2A89 FF18 5AE1 3B20 1F42 2D9B 91B2 2657 984A
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.
###Array ####Definition:
import config | |
class Ring(object): | |
""" | |
Acts as an implementation interface | |
""" | |
def add(self, *keys): | |
raise NotImplementedError |
class WordSearch(object): | |
def exist(self, board: [], word: str) -> bool: | |
for i in range(len(board)): | |
for j in range(len(board[i])): | |
if board[i][j] == word[0]: | |
if WordSearch.__search_adjacent(board, word[1:], i, j): | |
return True | |
return False |
class SudokuBacktracking(object): | |
def __init__(self, grid): | |
self.grid=grid | |
self.grid_size=9 | |
if not self.grid or len(self.grid)!=self.grid_size or len(self.grid[0])!=self.grid_size: | |
raise ('Must initialize the 9x9 board!') | |
def print_grid(self): | |
print('\n'.join(str(i) for i in self.grid)) |
from typing import List | |
class CombinationSum(object): | |
def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: | |
def dfs(comb, i, target, res): | |
if target == 0: | |
res.append(comb) | |
return | |
for j, x in enumerate(candidates[i:]): | |
if x <= target: |
class NumberCombination(object): | |
def number_combination(self, nums): | |
result = [] | |
tracker = [] | |
for x in nums: | |
for i in range(1,3): | |
if self.__ni_helper(x[0:i], x[i:], tracker): | |
result.append(tracker) | |
tracker = [] | |
return result |
from typing import List | |
class Permutation(object): | |
def permute(self, nums: List[int]) -> List[List[int]]: | |
def dfs(nums, permute, result): | |
if not nums: | |
result.append(permute) | |
return | |
for j, x in enumerate(nums): | |
dfs(nums[:j] + nums[j+1:], permute + [nums[j]], result) |