Coding Interview Patterns in Rust

My solutions in Rust for all the problems in the book : ISBN-10: 1736049135

  • Including Bonus.pdf

How to

  • Everything is on Github
  • One directory per chapter (01_two_pointers … 19_math_and_geometry)
  • In the directories, the number at the beginning of the filename (e.g., 10_xxx.ipynb, 14_yyy.ipynb) corresponds to the page number in the book.
  • When the filename starts with bonus_ the exercice is one of the bonus.pdf
  • A copy of bonus.pdf is available in the /assets directory

In most notebooks

  • I do NOT provide any explanation about the algorithm. Read the book.
  • There is a recap of the challenge at the top of the page
  • Then you will find the following sections
    • The point : The tip or the trick to keep in mind about the puzzle
    • Complexity : Recap of the time & space complexities
    • TODO : This is mostly for me
    • About Rust :
      • You will find here a list of function calls, idioms, constructs…
      • There is no order, no priority
      • This is mostly for me since I’m learning Rust
      • I can repeat some items from one solution to another if I have trouble to keep them in mind
      • I usually confirm if the code of the cell has been executed in the Rust Playground
    • There may be cells with code that doesn’t work and I explain why
    • If there are multiple versions of the same solution
      • I explain the changes from one version to the next.
      • If it make sense, I highlight if one of the versions is my Preferred solution
      • When we come back to a notebook with several versions, the lime color makes it easy to find the one I prefer (this is purely personal)

This how the beginning of a notebook may look like :

About the sample code

  • All code examples are self-contained. By that, I mean that, unlike the code presented in the book or in the associated GitHub repository, they are not just isolated functions; instead, each example includes a main() function where I demonstrate how to invoke the function and how to initialize any required data structures.
  • For example, in Chapter 11, which covers binary trees, all the solutions I provide create the trees used in the chapter and display the results. The idea is really that each piece of code should be self-sufficient and easy to run.
  • Yes, it results in more code, but I find it much more practical.
  • In most of the code examples, I try to keep the names of functions, variables… identical to those in the book.

Click on the image above to enlarge it.

What if you don’t run Rust code in Jupyter Notebook

  • Shame on you 😁. Read this README.
  • You can copy and paste the code of the cell of interest either :
    1. In a local project on your PC. Read this page where I share my setup on Windows 11.
    2. A better solution is to start by using the Rust Playground.
    3. In both cases, you may have to uncomment the line : fn main(){

This may help


Table of contents


Back to top

Published on: Jun 22 2025 at 03:00 PM | Last updated: Jun 22 1964 at 03:00 PM

Copyright © 1964-2025 - 40tude