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 heapq | |
class MaxHeapObj(object): | |
def __init__(self, val): self.val = val | |
def __lt__(self, other): return self.val > other.val | |
def __eq__(self, other): return self.val == other.val | |
def __str__(self): return str(self.val) | |
class MinHeap(object): |
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
"""" | |
Imagine you've been asked to review, and possibly refactor, the below code (of course, for the purpose of this interview, the code is intentionally poorly written). Think of your interviewer as your pair programming partner. You are expected to lead the exercise, but they are there to help you and provide guidance where appropriate. | |
Start by understanding and explaining what the code does. Feel free to make small changes as you go. There are also tests at the end that may help. | |
Next, try to get any failing tests to pass. | |
From there, come up with a plan for how you might improve the code. There may be both code and performance improvements. | |
We will block these segments by time, so don't be alarmed if we need to move to the next part. |
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
# ### Context | |
# At Traba, one way that we've grown our worker pool is by offering incentives for our existing workers to refer people in their network. We'd like to do some analysis on which workers have been responsible for the most worker acquisition. | |
# ### Prompt | |
# Given an array of worker id pairs, where the 0th index represents a worker on Traba and the 1st index, if defined, represents the worker that referred the aforementioned worker, write a function that determines which worker is responsible for the most referrals on Traba, direct or indirect. | |
# ### Examples |
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
{ | |
"workers": [ | |
{ | |
"id": "e60a8006-c57a-4d2e-9b35-99d88c9499f9" | |
}, | |
{ | |
"id": "c28c127b-d65e-4e04-926a-085e5809313b" | |
}, | |
{ | |
"id": "6deebc8e-719b-46ae-a123-aa8fde1a64dd" |
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
query = "Why are covid tests useful in the workplace?" | |
passage = "if it does. Ultimately, tests will help ensure that people can get back to work and will help reestablish public confidence in various sectors." | |
scores = [0.09, 0.01, 0.0, 0.9, 1.0, 0.4, 0.2, 0.6, 0.7, 0.8, 0.9, 0.9, 0.8, 0.7, 0.6, 0.02, 0.1, 0.01, 0.5, 0.2, 0.3, 0.0, 0.01, 0.00] | |
# Example of possible picks | |
# 0.9, 1.0, 0.4 | |
# 0.6, 0.7, 0.8, 0.9, 0.9, 0.8, 0.7, 0.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
# # Design a parking lot | |
# # Assumptions: | |
# # - The parking lot can hold motorcycles, cars and vans. | |
# # - The parking lot has spots of 3 sizes: small spots, medium spots and large | |
# # spots. | |
# # - A motorcycle can park in any spot. A car can park in a single medium spot, | |
# # or a large spot. | |
# # - A van can park, but it will take up 3 medium spots or a large spot. For the | |
# # purposes of this exercise, don’t worry about if the medium spots are next to |
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 csv | |
import sys | |
DEBUG = False | |
# We process two input CSV files that have the following field names: | |
LAST_NAME_FIELD = 'Last Name' | |
FIRST_NAME_FIELD = 'First Name' | |
EMAIL_FIELD = 'Email Address' | |
CELL_PHONE_FIELD = 'Cell Phone Number' |
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 copy | |
BOARD_FORMAT = '{} | {} | {}\n-----------\n{} | {} | {}\n-----------\n{} | {} | {}\n-----------\n' | |
class TicTacToe: | |
def __init__(self): | |
self.board = [[None, None, None], [None, None, None], [None, None, None]] | |
self.cur_turn = 'X' | |
def __repr__(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
# Rippling is at its core an employee database. | |
# Imagine if you’re at the early days of Rippling and you have admins asking for features around | |
# data reporting. | |
# The idea is that we want to build a system that allows admins to calculate values across many dimensions. | |
# Write a function that takes data blob as input (see example below) and calculates the sum | |
# of salaries in each department. | |
# [ | |
# { |
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
''' | |
A(3) | |
B(3) C(4) | |
D(1) E(2) | |
''' | |
max_avg_rating = 0 | |
max_avg_employee = None |
NewerOlder