Skip to content

Instantly share code, notes, and snippets.

class Program {
public static BinaryTree flattenBinaryTree(BinaryTree node) {
// O(n) time | O(d) space d -> depth of tree
flatten(node, null, null);
while (node.left != null) node = node.left;
return node;
}
static void flatten(BinaryTree node, BinaryTree left, BinaryTree right) {
boolean isLeftMost = node.left == null && left != null;
# Awa's problem:
# "Assume we have a list of words from the English dictionary, like:
# EnglishWords: ['water','big','apple','watch','banana','york','amsterdam','orange','macintosh','bottle','book'];
# And another long list of string to process, write a function to identify ""compound words"" and return them:
# input: ['paris','applewatch','ipod','amsterdam','bigbook','orange','waterbottle']
# output: ['applewatch','bigbook','waterbottle']
class SuffixTrie:
class Solution:
def rotate(self, matrix: list) -> None:
n = len(matrix)
for col in range(n//2):
for i in range(col, n-col-1):
startVal = matrix[col][i]
current = start = (col, i)
while True:
next_ = self.getNext(current, n)
https://github.com/GoogleChrome/puppeteer/issues/299#issuecomment-474435547
def decode(word, index=0):
word_set = []
while index < len(word):
char = word[index]
if char == ']':
break
elif char.isdigit():
new_word_set, index = decode(word, index + 2)
word_set = word_set + int(char) * new_word_set
else:
def longest_substring(word):
longest = current = 0
seen = {}
for i in range(len(word)):
character = word[i]
if character in seen:
longest = max(longest, (i - seen[character]))
current = 0
current += 1
seen[word[i]] = i
@tonymontaro
tonymontaro / User-Centric-ReadMe.md
Last active January 31, 2019 05:32
Simplified README for CodeInstitute User-Centric Project

Your Project's Name

One or two paragraphs providing an overview of your project.

Essentially, this part is your sales pitch.

UX

  • Describe what the website is used for here
flask run --host=0.0.0.0 --port=8080
python manage.py runserver "0.0.0.0:8080"
# install python 3.6 on ubuntu
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -y python3.6
# I have a helper function to nuke everything docker, erm... continuously. Basically it boils down to the following:
# To clear containers:
docker rm -f $(docker ps -a -q)
# To clear images:
docker rmi -f $(docker images -a -q)
# copy to clipboard
cat ~/.ssh/id_rsa.pub | clip.exe