Be prepared

2017-04-03
EPI in Python

EPI in Python was the single biggest ask from our readers, and we’re very happy to tell you that EPI in now available in Python! You can buy it directly from Amazon here.

We’ve been using Python as our daily language at Facebook and Uber for quite some time now, and have grown to appreciate its power, versatility, and aesthetics. We wrote Python code for EPI Python from the ground up, and invested a great deal of effort to find the most efficient ways to solve interview problems in Python.

We hope you enjoy reading this book as much we we enjoyed writing it. As always, we look forward to hearing our readers thoughts and criticisms of our work. Feel free to drop us a line, come by in person if you are in the Bay Area. (Ice Cream at the Facebook Sweet Shop is always fun.)

Read More

2016-06-22
EPI variants and versions

This post clarifies questions we are often asked about EPI versions and variants.

Variants

There are two basic printed variants: Elements of Programming Interviews (which is in C++), and Elements of Programming Interviews in Java.

Each comes in two sizes: 6” x 9” and 7” x 10” - the latter uses a larger font and greater line spacing. The smaller and larger formats contain exactly the same content.

Amazon does a poor job of showing the variants. Here’s direct links to them:

Versions

People are often confused the publication dates, e.g., October 2012 date listed for the original 6 in x 9 in EPI (C++).

EPI has changed enormously since the initial release - the first release came at commit 1200, we are now at commit 3900. On the way we’ve added and removed problems, features, and content, based on trends we’ve seen at interviews. We regularly upload updated PDF to Amazon’s on-demand publishing arm, and it goes live immediately.

For this reason we very strongly recommend that you buy only from Amazon itself, not from resellers on Amazon. Regardless of the advertised release date, the version sold by Amazon itself is always current - resellers may be selling old stock, or even worse, pirated copies which have very poor print quality.

Read More

2016-05-19
Dear readers - we need your help to select a new cover!

To celebrate all the changes we have made to EPI since its first release, we are creating a new cover.

We held a design competition, and we would like you to help us pick from the finalists. Click here to vote on covers. (Direct link to poll: http://bit.ly/epicover2)

Here is a screenshot of the poll.

Read More

2016-02-25
Please help us review some exciting new features!

New features

EPI is a community book - its content, quality, and very existence, are a testament to the engagement and enthusiasm of its readers.

In this spirit, we are asking readers to help us by providing feedback on some new material we’ve been working on. Specifically, based on your feedback, we are adding the following features to EPI:

  • Expanded introductions for each chapter. These introductions include
    • An example that illustrates the key data structures and algorithms for that chapter, e.g., how to use binary search with a custom comparator.
    • A table of top-tips for the chapter, e.g., consider reversing arrays of digits to operate on the least-significant digit first.
    • A review of the most important library methods, e.g., Arrays.asList(1,3,5).
  • More domain specific questions. Specifically, in addition to the existing chapter on system design problems, we are adding the following chapters.
    • Programming language questions, e.g., the difference between final and finally.
      a Object-oriented principles, e.g., explain the difference between a class adapter and an object adapter.
    • Tool questions, e.g., describe the role of merging in a version control system.

By acting as a reviewer, you will get

  • a chance to perfect your interviewing skills,
  • an early look at the book,
  • our undying gratitude, and,
  • a free hardcopy of the book, if you are one of the first 25 reviewers or make great contributions to this review.

If you are interested, please sign up via this Google form.

We expect reviewers to spend one to two afternoons going through the assigned material, and identify an issue every 1 to 2 pages.

The perfect is the enemy of the good - please send us your inputs as soon as you can. (We are hoping to have a substantial amount of feedback by mid April.

Issues can be typos, language that is misleading, suboptimum solutions, bad programming practices - in short anything that can improve the quality of the book. Every individual issue you identify should be reported through a Google form, which you can view here.

Here are some examples of issues reported by readers. Note how specific these suggestions are - they have details on where the issue was, what the problem was, what the right wording should be, etc.

  • Suggestion: Solution 12.14: I feel that the limitations of the template method particularly in C++ should be addressed.
  • Typo: The account of HTTPS consistently spells certificate as sertificate.
  • Suggestion: Drop Variant 10.16.1, as it is effectively the same as Problem 10.18.
  • Clarification: I don’t see how it’s possible to sort in O(n) time, as suggested by the writeup at the start of Chapter 13.
Read More

2015-12-04
Introducing the EPI online judge

July 7, 2016

We’re closing the judge service for the near future as we take the lessons learned and build out a more robust and full-featured service.

Jan 14, 2016

We’ve put together a prototype online judge service that you can use to practice for interviews.

Take a look at the screenshot at the end to see the UI, or just click on the link.
No login is needed, just read the problem description and start hacking!

The judge problems correspond to the problems in the PDF sample. These problems are an ideal starting point for anyone who wants to get up to speed with interviewing. (Right now, all programs are in Java.)

Usage

We use directed tests for the judge problems, and try to give meaningful feedback. For example, if your program for testing if a binary tree is balanced fails, you will see a report like the following.

1
Incorrect result on balanced tree {0,1,2,3,#,4,5}

If your program fails to compile, we return the compiler error, and the line numbers will correspond to the lines in your program.

1
2
3
4
5
6
Line 7: error: incompatible types
int y = "asd";
^
required: int
found: String
1 error

If your program throws an exception, we return the stacktrace - the line numbers will not correspond to the lines in your program.

1
2
3
Exception in thread "main" java.lang.RuntimeException
at BalancedBinaryTree.isBalanced(file.java:49)
at BalancedBinaryTree.main(file.java:86)

Your program runs in Docker container, so don’t worry about crashing or damaging our server. We run the program with a timeout of 20 seconds, so if your program has an infinite loop, or is very slow, you’ll get a timeout response. If the server is under load, it may block requests that are too frequent.

A few programs require you to have an efficient solution to pass, e.g., if you brute-force compute the parity, you will see the judge informs you that your solution is too slow:

1
Execution Timed Out

Plans

We’re very excited about offering this service, and look forward to developing it - adding more problems, adding a login and persisting your code, classification of problens, drag-and-drop into the editor, executing from Github, etc.

Reader Input

As always, we treasure user input. Please share your thoughts with us about the judge. Some things we’re especially keen on learning about are:


  1. Bugs, e.g., program never returns, hint button doesn’t work, etc.
  2. Source of confusion, e.g., misleading stack traces, wording of error
  3. General UI issues: is editor font ok? do you prefer a light background?
  4. How important are features like login, timing, etc.?

Read More

2015-09-23
Elements of Programming Interviews in Java

The Java version of EPI is in press ready!

It should be available from Amazon in a few days.
We will post a direct link to the Amazon page when it is ready.

It’s here!

Link to Amazon page
for EPI in Java.


The only difference between the original EPI and EPI in Java is that
the programs are now in Java instead of C++. (We also have a short chapter
on Java, which includes best coding practices for an interview and a small
number of language review questions; this replaces the similar chapter on C++
in the original EPI.)

All programs, Java and C++, are always available from the website.

We will continue to sell the original EPI for readers who prefer C++.

Read More

2015-09-09
EPI back at Amazon

EPI is not currently available from Amazon, we are working on this issue

As of 12:43 CDT 9/15/2015, EPI is available again!
Read More

2015-08-20
EPI in Java

The draft version of EPI in Java is ready!

EPI is a community book - its content, quality, and very existence,
are a testament to the engagement and enthusiasm of its readers.

In this spirit, we are asking readers to help us by providing
feedback on 1-2 chapters on the Java draft.

By acting as a reviewer, you will get


  1. a chance to perfect your interviewing skills,
  2. an early look at the book,
  3. our undying gratitude, and,
  4. a free hardcopy of the book, if you are one of the first 25 reviewers or make great contributions to this review.

If you are interested, please sign up via this –>Google form.

Due to enormous interest, we are no longer signing up reviewers. If you are very keen on participating,
please write directly to us - you can use adnan.aziz@gmail.com.

We expect reviewers to spend one to two afternoons going through
the chapter, and identify an issue every 1 to 2 pages. The text is very similar to that of
the current version - the big difference is in the programs which are now in Java.

The perfect is the enemy of the good - please send us your inputs as soon as you can. (We are hoping
to have a substantial amount of feedback by the end of August.)

Issues can be typos, language that is misleading, suboptimum solutions, bad programming practices - in short
anything that can improve the quality of the book.
Every individual issue you identify should be reported through a Google form, which you
can view here.

Here are some examples of issues reported by readers.
Note how specific these suggestions are - they have details on where the issue was, what the problem was, what the right wording should be, etc.


  1. Typo: 3rd paragraph, 3rd line: “<0, 7="" 0,="" 2,="" 3,="" 5,="">“. According to the input array, it should be “<0, 7="" 0,="" 2,="" 3,="" 6,="">“, because when we reach day 6, the max profit is 14 - 8 = 6, not 14 - 9 = 5.
    This means on the last line of this paragraph, the last two elements in M should be 8 and 6 (instead of 7 and 5).
  2. Comment: Why in problem 6.19 and the variant, we need to assume that n = 2^k? This condition is not really used in current solutions (unless you meant to discuss an alternate solution that uses divide and conquer to rotate the matrix by quarters).
  3. Clarification: Solution 12.14: I feel the parameters in recursive function are confusing. Would it not be better to use two integers to keep track of the number of left parens we need and the number of right parens we need? If the first one is larger than 0, then we can add either left or right paren; otherwise we just add right parens. When both are 0, we save the valid prefix.
  4. Error: Program in Solution 8.4 goes into an infinite loop
    if there are duplicates entries in the input list. The problem statement should either explicitly
    rule that out, or you should use a container which supports duplicate entries.
  5. Suggestion: Drop Variant 10.16.1, as it is effectively the same as Problem 10.18.
Read More

2015-04-03
EPI Problem Solution Integration

A number of readers have suggested integrating solutions with problems, that is presenting
the solution immediately after the problem. Their goal is to avoid having to go back
and forth.

This has been particularly challenging for readers using the Ebook - Google Play strips
the links we provide in the PDF between problems and solutions (and also to page and figure references).

We have updated EPI to have this integration. The new version is now available from Amazon.

If you have an Ebook, you can always get the latest version for free from Google Play.

Happy Reading,
The EPI Team

Read More

2015-04-01
Warming Up

The programming exercises in EPI are representative of what you will be asked
in an interview. We do not provide textbook-style review questions.

In this document, we present a small set of programming exercises suitable for
someone who needs to review basics. (You are unlikely to be
asked these questions - their purpose is to bootstrap reading EPI.)

When you write your solutions to these exercises, please code to the following constraints:


  1. Do not use library calls.
  2. Do not try to design clever solutions. (This means it is fine to use brute-force approaches.)
  3. Assume valid inputs, and ignore internal errors like overflow, IO exceptions, etc.
  4. Write unit tests for your programs.
  5. Analyze your programs for time and space complexity.

Exercises, one for each EPI chapter


  1. Primitive types: write a program that takes as input an integer, N, and prints
    all the integers from 1 to N, replacing numbers divisible by 3 with “fizz”, numbers divisible by
    5 with “buzz”, and numbers divisible by both with “fizz buzz”.
  2. Arrays: Write a program that tests if a 2D square array is symmetric about the diagonal
    from (0,0) to (n-1,n-1).
  3. Strings: Write a program to find the longest substring that consists of a single
    character in an input string.
  4. Linked Lists: Implement a doubly linked list of integers class. Write a reverse method for your list class
    that reverses a list without changing the node contents.
  5. Stacks and Queues: Write a programt to evaluate arithmetical expressions that use + and applied
    to nonnegative integer arguments. Expressions are in reverse-Polish notation, e.g., 3 4 + 5
    , 1 3 + 5 7 + *.
  6. Binary Trees: Write inorder, preorder and postorder traversal methods for a binary tree. (You will need
    to implement a class suitable for representing binary trees, but do not need to implement
    add, lookup, delete, etc. methods.)
  7. Heaps: Write a program that builds a max-heap from an integer array. (You will need to implement
    a class suitable for representing heaps, but do not need to implement extract-max, insert key, etc.)
  8. Searching: Write a nonrecursive program to perform binary search over a sorted array.
  9. Hash tables: Write a program that finds the most common object in an array of objects. The
    objects consists of pairs of strings. Treat strings as being the same if they are equal when converted to lower case.
  10. BSTs: Write a program that searches a BST on integer keys for a given value. (You will need to
    implement a class suitable for representing BSTs, but do not need to implement
    add, lookup, delete, etc. methods.)
  11. Write a recursive program that takes as input positive integers x and N, and returns x to the power N.
    You should use O(log N) multiplications.
  12. Dynamic Programming: Write a program that takes a positive integer N, and returns the number
    of binary strings of length N such that there are no consecutive 1s. For example, if N = 3, the result
    is 5, corresponding to the strings 000, 001, 010, 100, 101.
  13. Greedy Algorithms and Invariants: Write a program that takes an input a positive integer
    N, and returns the minimum number of coins in the US coinage system to create N cents. For example, if
    N = 37, the answer is 4, corresponding to a quarter, a dime, and two pennies.
  14. Graphs: Implement Depth First Search and Breadth First Search. (You will need to implement
    classes suitable to representing graphs.)
  15. Parallel Computing: Write a program which uses two threads to print the numbers from
    1 to 100 in order. One thread can only print odd numbers, the other can only print even numbers.
Read More