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.

Solutions are written for Python 3.4.

Compute parity

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

Convert base

convert_base.py

Compute the max-difference

robot_battery.py

Interconvert strings and integers

interconverting_string_integer.py

Reverse all the words in a sentence

reverse_words.py

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

balanced_binary_tree.py

Merge sorted arrays

merge_sorted_arrays.py

Search a sorted array for the first occurrence of K

binary_search_first_k.py

Test if an anonymous letter is constructible

anonymous_letter.py

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

rendering_calendar.py

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

3-sum.py

Paint a Boolean matrix

painting_iterative.py painting_recursive.py

Analyze two unsynchronized interleaved threads

two_thread_increment.py

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.