/Elements-of-Programming-Interviews

EPI Judge - Preview Release

Primary LanguagePythonOtherNOASSERTION

EPI Judge

Introduction

EPI Judge is meant to serve as a companion to Elements of Programming Interviews in Python.

This repository contains solutions implemented by Long Nguyen.

Running the judge from the command line

Python

$ python3 <program_name>.py

Problems completed

Arrays

  • 5.1 Sort via the Dutch national flag
  • 5.2 Add 1 to an arbitrary integer
  • 5.3 Multiply 2 arbitrary-precision integers
  • 5.4 Advance through an array
  • 5.5 Remove duplicates from a sorted array
  • 5.6 Buy and sell a stock
  • 5.7 Buy and sell a stock twice
  • 5.8 Compute an array alternation
  • 5.9 Compute all primes up to n
  • 5.10 Permute an array given a permutation
  • 5.11 Compute the next permutation
  • 5.12 Sample offline data
  • 5.13 Sample online data
  • 5.14 Compute a random permutation
  • 5.15 Compute a random subset
  • 5.16 Generate nonuniform random numbers
  • 5.17 Check a Sudoku board
  • 5.18 Compute a matrix's spiral ordering
  • 5.19 Rotate a matrix
  • 5.20 Compute rows of Pascal's Triangle

Strings

  • 6.1 Convert between strings and integers
  • 6.2 Base conversion
  • 6.3 Compute the spreadsheet column encoding
  • 6.4 Replace and remove
  • 6.5 Test palindromity
  • 6.6 Reverse all the words in a sentence
  • 6.7 Compute all mnemonics for a phone number
  • 6.8 Look and say
  • 6.9 Conver from Roman to decimal format
  • 6.10 Compute all valid IP addresses
  • 6.11 Write a string sinusoidally
  • 6.12 Implement run-length encoding
  • 6.13 Find the first occurrence of a substring

Linked lists

  • 7.1 Merge two sorted lists
  • 7.2 Reverse a single sublist
  • 7.3 Test for cycles in a linked list
  • 7.4 Test for overlapping lists (acyclic)
  • 7.5 Test for overlapping lists (cycles allowed)
  • 7.6 Delete a node from a singly-linked list
  • 7.7 Remove the k-th last element from a linked list
  • 7.8 Remove duplicates from a sorted linked list
  • 7.9 Cyclic right shift for a singly-linked list
  • 7.10 Even-odd merge
  • 7.11 Test whether a singly-linked list is palindromic
  • 7.12 Linked list pivoting
  • 7.13 Add list-based integers

Stacks & queues

  • 8.1 Implement a stack with a Max() API
  • 8.2 Evaluate an RPN expression
  • 8.3 Test a parenthesized string for wellness
  • 8.4 Normalize pathnames

Binary trees

  • 9.1 Check if a binary tree is balanced
  • 9.2 Check if a binary tree is symmetric
  • 9.3 Find the lowest common ancestor of a binary tree
  • 9.4 Find the lowest common ancestor given nodes with parent pointers

Heaps

  • 10.1 Merge sorted files
  • 10.2 Sort an increasing-decreasing array
  • 10.3 Sort an almost-sorted array
  • 10.4 Find the k closest stars to Earth

Searching

Hash tables

  • 12.1 Test for palindromic permutations
  • 12.2 Is an anonymous letter constructible?
  • 12.3 Design an LRU cache
  • 12.4 Find the lowest common ancestor efficiently with a hash table

Sorting

  • 13.1 Compute the intersection of two sorted arrays
  • 13.2 Merge two sorted arrays
  • 13.3 Remove first-name duplicates
  • 13.4 Smallest nonconstructible change value

Binary search trees

  • 14.1 Determine whether a binary tree satisfies the BST property
  • 14.2 Find the first key greater than a given value in a BST
  • 14.3 Find the k largest values in a BST
  • 14.4 Find the lowest common ancestor in a BST

Recursion

  • 15.1 Towers of Hanoi
  • 15.2 n-Queens
  • 15.3 Generate all permutations
  • 15.4 Generate the power set

Dynamic programming

  • 16.1 Count the number of score combinations
  • 16.2 Edit distance
  • 16.3 Number of ways to traverse a matrix from top left to bottom right
  • 16.4 Compute binomial coefficients

Greedy algorithms / invariants

  • 17.1 Compute an optimal task assignment
  • 17.2 Generate a schedule that minimizes waiting time
  • 17.3 Interval covering
  • 17.4 3-Sum
  • 17.5 Find the mode of a sequence
  • 17.6 The gasup problem
  • 17.7 Maximum amount of water trapped by two bounding walls
  • 17.8 Compute the largest rectangle under a skyline

Graphs

  • 18.1 Searching a maze
  • 18.2 Paint a boolean matrix
  • 18.3 Compute enclosed regions
  • 18.4 Deadlock detection

Tracking your progress

The file index.html in the root of this project tracks your progress through the problems. Specifically, there's an expanding tab for each chapter. Click on it, and you will see your progress, e.g., as below. This file gets updated each time you execute a program. You can use this file to map book problems to stub programs.

Progress UI