Home - Elements of Programming Interviews

Elements of Programming Interviews

Latest Post

27 February 2015

EPI in Python

We've begun the process of writing Python solutions!

Python versions of the program in the EPI sampler are listed below and we would really appreciate your thoughts on them with respect to idiomaticity and clarity.

Python has exceptionally powerful libraries. Our programs by design use a simple subset of the library but in many cases we also provide alternative Pythonistic solutions.

Compute parity

parity.py parity1.py parity2.py parity3.py parity4.py

Convert base


Compute the max-difference


Interconvert strings and integers


Reverse all the words in a sentence


Test for cyclicity

linked_list_prototype.py checking_cycle.py checking_cycle_alternative.py

Stack with max API

stack_with_max.py stack_with_max_improved.py

Print a binary tree in level order

binary_tree_prototype.py binary_tree_level_order.py

Test if a binary tree is balanced


Merge sorted arrays


Search a sorted array for the first occurrence of K


Test if an anonymous letter is constructible


Compute the intersection of two sorted arrays

intersect_sorted_arrays.py intersect_sorted_arrays1.py intersect_sorted_arrays2.py intersect_sorted_arrays3.py

Render a calendar


Test if a binary tree satisfies the BST property

is_binary_tree_a_bst.py is_binary_tree_a_bst_bfs.py is_binary_tree_a_bst_const_space.y

Enumerate the power set

power_set.py power_set_alternative.py

Count the number of ways to traverse a 2D array

number_ways.py number_ways_obstacles.py

The 3-sum problem


Paint a Boolean matrix

painting_iterative.py painting_iterative.py

Analyze two unsynchronized interleaved threads


Many of the best ideas in the book (e.g., the study guide, ninja notation, the C++11 review) came from reader feedback. Please write to us, or post on the discourse forum, with suggestions for improvement.