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
""" | |
Scamming the coding interview | |
""" | |
def calculate_pow(base, exp, m): | |
if exp == 1: | |
return base |
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
""" | |
Scamming the coding interview | |
""" | |
def get_number_of_ways(n, m): | |
matrix = [ | |
[0 for j in range(0, m)] for i in range(0, n) | |
] |
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
""" | |
Scamming the coding interview | |
""" | |
from collections import defaultdict | |
def pre_process_matrix(matrix): | |
letter_to_position_map = defaultdict(list) |
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
""" | |
Scamming the coding interview | |
""" | |
def calculate_rain_water_trapped(bars): | |
n = len(bars) | |
left = [0 for i in range(0, n)] | |
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
""" | |
Scamming the coding interview. | |
Subscribe to our newsletter at https://scammingthecodinginterview.com/ | |
to get a coding or design problem daily in your inbox and become exceptionally good at | |
coding interviews. | |
""" | |
class FrequencyNode(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
""" | |
Scamming the coding interview. | |
Subscribe to our newsletter at https://scammingthecodinginterview.com/ | |
to get a coding or design problem daily in your inbox and become exceptionally good at | |
coding interviews. | |
""" | |
from fractions import Fraction | |
from functools import reduce | |
from operator import mul |
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
""" | |
Scamming the coding interview. | |
Subscribe to our newsletter at https://scammingthecodinginterview.com/ | |
to get a coding or design problem daily in your inbox and become exceptionally good at | |
coding interviews. | |
""" | |
def find_nth_perfect_number(n): |
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
""" | |
Scamming the coding interview. Problem 013 | |
Subscribe to our newsletter at https://scammingthecodinginterview.com/ | |
to get a coding or design problem daily in your inbox and become exceptionally good at | |
coding interviews. | |
""" | |
from random import randint | |
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
""" | |
Scamming the coding interview. Problem 014 | |
Subscribe to our newsletter at https://scammingthecodinginterview.com/ | |
to get a coding or design problem daily in your inbox and become exceptionally good at | |
coding interviews. | |
""" | |
class Node(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
""" | |
Scamming the coding interview. Problem 015 | |
Subscribe to our newsletter at https://scammingthecodinginterview.com/ | |
to get a coding or design problem daily in your inbox and become exceptionally good at | |
coding interviews. | |
""" | |
class Node(object): |