Skip to content

Instantly share code, notes, and snippets.

View priyankvex's full-sized avatar
💭
Chilling 🍺

Priyank Verma priyankvex

💭
Chilling 🍺
View GitHub Profile
@priyankvex
priyankvex / calculate_exponentiation.py
Last active December 19, 2018 10:10
Scamming the coding interview: Problem 007: Calculate exponenetiation
"""
Scamming the coding interview
"""
def calculate_pow(base, exp, m):
if exp == 1:
return base
@priyankvex
priyankvex / number_of_ways_in_a_matrix.py
Created December 20, 2018 14:09
Scamming the coding interview: Problem 008: Number of ways in the matrix
"""
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)
]
@priyankvex
priyankvex / find_word_in_the_matrix.py
Created December 21, 2018 07:45
Scamming the coding interview: Problem 009: Find word in the matrix
"""
Scamming the coding interview
"""
from collections import defaultdict
def pre_process_matrix(matrix):
letter_to_position_map = defaultdict(list)
@priyankvex
priyankvex / rain_water_trapped.py
Last active December 24, 2018 17:11
Scamming the coding interview: Problem 010: Rain water trapped
"""
Scamming the coding interview
"""
def calculate_rain_water_trapped(bars):
n = len(bars)
left = [0 for i in range(0, n)]
@priyankvex
priyankvex / lfu_cache.py
Created December 25, 2018 17:53
Scamming the coding interview: https://scammingthecodinginterview.com/ : Problem 011 : LFU cache
"""
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):
@priyankvex
priyankvex / bishops_attacking_each_other.py
Last active December 26, 2018 14:52
scammingthecodinginterview.com : Problem 012 : Bishops attacking each other
"""
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
@priyankvex
priyankvex / perfect_number.py
Created December 28, 2018 14:42
Scamming the coding interview : Problem 013 : Find the nth perfect number
"""
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):
@priyankvex
priyankvex / unbiased_coin_toss_from_biased_coin.py
Created December 29, 2018 10:39
Scamming the coding interview : Problem 013 : Unbiased coin toss from a biased coin.
"""
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
@priyankvex
priyankvex / maximum_frequency_value_graph_path.py
Created December 31, 2018 15:21
Scamming the coding interview : Problem 014 : Maximum frequency path in a graph
"""
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):
@priyankvex
priyankvex / reverse_linked_list.py
Created January 1, 2019 14:24
Scamming the coding interview : Problem 015 : Reverse the linked list
"""
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):