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
import datetime | |
question = """ | |
You are building stories into an app. Your inputs are an object with the | |
structure { username, postedAt }, and a date in the future. Each story lives for | |
24 hours. Write a function that outputs the stories that are visible for the | |
inputted time. | |
""" |
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
import re | |
question = """ | |
You’re given a string of characters that are only 2s and 0s. Return the index of | |
the first occurrence of “2020” without using the indexOf (or similar) function, | |
and -1 if it’s not found in the string. | |
Example: | |
$ find2020(‘2220000202220020200’) |
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
import math | |
question = """ | |
You’re trying to build an IoT mesh network. Signals can only travel the maximum of 5 units. | |
You’re given coordinates for the switch, the light, and the mesh hubs (which capture and forward | |
signals). Return true if the switch can successfully toggle the light. | |
Example: | |
let network = { switch: [0,1], hub: [[2,1], [2,5]], light: [1,6] } |
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
from itertools import product | |
question = """ | |
Given a n x m binary matrix filled with 0s and 1s, find the largest rectangle | |
containing only 1s and return its area. | |
Example: | |
$ matrix = | |
['1','0','1','0','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
import os.path | |
from os import path | |
import csv | |
question = """ | |
Design a hashmap without using any built-in libraries. You should include the following functions: | |
- put(key, value): Insert a (key, value) pair into the hashmap. If the value | |
already exists, update the value. |
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
question = """ | |
Given an n x n array, rotate it 90 degrees without making a new array. | |
Example: | |
$ rotate90([[1,2,3],[4,5,6],[7,8,9]]) | |
$ [[7,4,1],[8,5,2],[9,6,3]] | |
""" |
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
question = """ | |
You are given a snapshot of a queue of stocks that have changing prices coming in from a stream. Remove the outdated stocks from the queue. | |
Example: | |
$ snapshot = [ | |
{ sym: ‘GME’, cost: 280 }, | |
{ sym: ‘PYPL’, cost: 234 }, | |
{ sym: ‘AMZN’, cost: 3206 }, | |
{ sym: ‘AMZN’, cost: 3213 }, |
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
from functools import reduce | |
question = """ | |
This week’s question: | |
Implement a ProductList class that has two methods, | |
add(n) (which pushes the value n to the back of the list) and | |
product(m) (which returns the product of the last m numbers in the list). | |
David made an awesome template for submitting your solutions, if you’d like to use it! |
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
question = """ | |
Given a string str and a dictionary dict containing a list of non-empty words, add spaces in | |
str to construct a “sentence” where each word is a valid word in dict. Return all possible | |
sentences. You are allowed to reuse the words in dict. | |
Example: | |
str = “penpineapplepenapple” | |
dict = [“apple”, “pen”, “applepen”, “pine”, “pineapple”] | |
$ makeSentence(str, dict) $ [ “pen pine apple pen apple”, “pen pineapple pen apple”, |
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
import re | |
question = """ | |
Given a string str containing only the characters x and y, change | |
it into a string such that there are no matching adjacent characters. | |
You’re allowed to delete zero or more characters in the string. | |
Find the minimum number of required deletions. | |
Example: |