Skip to content

Instantly share code, notes, and snippets.

View HauptJ's full-sized avatar
:octocat:
Tschüss STL

Joshua Haupt HauptJ

:octocat:
Tschüss STL
View GitHub Profile
def flatten_dictionary(dictionary):
flattened = {}
flattened = flatten_helper("", dictionary, flattened)
return flattened
def flatten_helper(initKey, dictionary, flattened):
for k, v in dictionary:
if not isInstance(v, dict):
if initKey is None or initKey == "":
from collections import deque
class Solution:
def wallsAndGates(self, rooms: List[List[int]]) -> None:
"""
Do not return anything, modify rooms in-place instead.
"""
if not rooms:
return 1
class Solution:
def permute(self, nums: List[int]) -> List[List[int]]:
list = []
tempList = []
def backtrack(list, tempList, nums):
if len(tempList) == len(nums):
list.append(tempList)
else:
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the candies function below.
def candies(n, arr):
class Solution {
static int WHITE = 0, GRAY = 1, BLACK = 2;
private int V;
private LinkedList<Integer> adj[];
Graph(int v) {
V = v;
from collections import defaultdict
class Solution:
def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool:
gra = Graph(len(prerequisites))
for preReq in prerequisites:
gra.addEdge(preReq[0], preReq[1])
func canFinish(numCourses int, prerequisites [][]int) bool {
next := Next(numCourses, prerequisites)
pres := Pres(next)
return check(next, pres, numCourses)
}
func Next(n int, prereq [][]int) [][]int {
next := make([][]int,n)
for _, pair := range prereq {
def calc_drone_min_energy(route):
if not route:
return 0
initialz = route[0][2]
greatestz = initialz
for z in range(1, len(route), 1):
class Solution:
def kClosest(self, points: List[List[int]], K: int) -> List[List[int]]:
"""
in: List, K
out List
Time: NLogN due to sorting
Space: N due to dictionary
"""
class Solution:
def repeatedNTimes(self, A: List[int]) -> int:
for i in range(len(A)):
if A.count(A[i]) == len(A)//2:
return A[i]
"""