Not confident with recursion? No worries —here’s the how-to guide for solving DP problems with a bottom-up approach.

Dynamic Programming (DP) is a funny term. It was named as such to avoid enraging a former Secretary of Defense, and the name has stuck ever since.

Image for post
Image for post

Essentially, there’s nothing dynamic about it. DP can simply be categorized as an algorithmic strategy where one breaks down a single problem into sub-problems. By solving each sub-problem, the algorithm gets closer and closer to solving the original problem. After solving all of the sub-problems, the answer to the original problem is found.

Experienced readers will most likely think that this definition is very close to the idea of recursion — it definitely is, and most problems that employ a DP solution can be solved with recursion. …


The classic backtracking problem, demystified with diagrams and thorough explanations.

Image for post
Image for post

Permutations is not an easy problem. For those who haven’t seen a backtracking question before, there is no clear naive solution, and this poses a real threat for software engineers during interviews.

Luckily, there is a method for solving questions like Permutations. In this article, the question will be broken down and then be solved using exposition and several diagrams.

Be sure to read carefully and draw out the diagrams as they appear in the article. This practice will make solving problems like Permutations much easier on subsequent exposure.

NOTE: It is assumed that readers are comfortable with recursion.

Permutations Breakdown

First, one needs to break down the problem thoroughly. Let’s read the description and explore any questions that arise from it. …


Learn how to create, read, update, and destroy data from the database with models.

Image for post
Image for post

Ruby on Rails is the premier example of a framework that uses the MVC architectural pattern. The M stands for model, and models are used in Rails to represent business data and logic.

In Rails, business data is represented as objects that hold data and require persistence in a database. Active Record is the layer responsible for creating and using the aforementioned business objects.

Now, back to models: a model is what Active Record uses to instantiate hashes (objects) that represents rows from the database.

For instance, if one had a monsters table in the database, the corresponding model in Active Record would be Monster and may have the following…


Protect Express applications from cross-site request forgeries with a minimum of hassle and middleware.

Security is of paramount concern for all developers, and especially for developers using unopinionated web frameworks, like Express.

Since Express doesn’t have opinions about the correct way to create applications, it also does not have opinions about the correct way to secure applications. Securing the application, then, is a task left solely to the developer.

Luckily, it isn’t absurdly difficult to secure an Express application from common vulnerabilities on the web.

This article will focus on preventing CSRF, which stands for cross-site request forgery.

CSRF Explained

A cross-site request forgery occurs when a user who is authenticated on a site is forced to make an unwanted request to that site. This request originates from a different origin, and that’s what makes this is a cross-origin request forgery.


Design beautiful objects in JavaScript using this simple explanation of Kyle Simpson’s OLOO design pattern.

Every JavaScript developer knows that Objects are powerful; however, JavaScript’s objects also have a unique type of inheritance which grant them novel space-saving capabilities.

This type of inheritance is called Prototypal Inheritance, and this type of inheritance makes OLOO possible.

OLOO stands for Objects Linking to Other Objects, and is an object design pattern.

One must understand the absolute basics of prototypal inheritance before being able to use OLOO effectively.

Image for post
Image for post
This isn’t JavaScript!

Prototypal Inheritance Made Simple

Unlike class-based languages, like Java and C#, JavaScript only has one construct which uses inheritance: the object.

Every object has a private property which holds a link to another object known as its prototype. …


Solve the classic interview problem in linear time without sorting.

Two Sum — It’s possibly one of the most prolific algorithm questions in existence, and as such, should be practiced extensively.

Even though it is a common question, there are many variants to this problem that could trip up a developer in an interview.

One constraint that could be used in an interview would be to disallow sorting the input array. This constraint is a great way to assess if a candidate has a thorough understanding of data structures and their possible time complexities.

This article will go into a deep dive on Two Sum. …


Understanding closures is the key to implementing private data in JavaScript.

As everyone knows, JavaScript has good parts and bad parts.

This makes the job of a developer very easy:

  1. Use the good parts.
  2. Don’t use the bad parts.

One of the good parts of JavaScript are closures. A closure is created by defining a function. The function and the variables inside the function’s block retain access to the data that is in scope at the time of definition. This is an immensely powerful tool. …


Slide into linear time with two pointers, a loop, and a little patience.

Image for post
Image for post

Before sliding into linear time with the Sliding Window algorithm, one should understand the metrics by which an algorithm is deemed efficient.

To illustrate this, the following quote by Antoine de Saint-Exupéry, the author of The Little Prince, should suffice.

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.

This is beautifully written and seemingly profound, but what relevance does it hold for software engineers, developers, and their algorithms?

First, an algorithm is a set of steps used to achieve some goal. People use algorithms every day of their lives. Take the morning commute, for instance. …


After all, a successful gem makes a Ruby programmer’s life easier

Image for post
Image for post

Exploring the simple beauty of the Ruby language, it’s difficult to think of improvements that could be made to make programmers’ lives easier. However, this happens more than you may think, and these improvements often are shared with others in the form of Ruby gems.

A gem is a packaged library or application that can be installed with a tool known as RubyGems. So long as one’s Ruby version is at least 1.9, RubyGems has already been installed alongside the Ruby installation.

Some of the most helpful gems are Bundler, Rake, and Minitest, each with millions of downloads and just as many happy users. The hallmark of a gem is its ability to make a Ruby programmer’s life easier; if an idea has the capacity to do just that, it should be shared with the rest of the Ruby community. …


Anyone who has used Ruby has most likely internalized one truth:

Everything in Ruby is an object.

Image for post
Image for post
These are objects according to Ruby.

This truth is inescapable, undeniable, and persistent. Ruby’s ability to store anything as an object is immensely powerful.

However, when writing to different file types from within Ruby, how can we store the objects created in our program and access them later?

Let’s say we had a .txt file, and we wrote to it from within our Ruby program. How could we store an object in that file?

One method for storing objects from Ruby is to use a YAML file.

YAML stands for “YAML Ain’t Markup Language”, and is a human friendly data serialization standard for all programming languages. We can use YAML files in conjunction with our Ruby program to store objects, and in the case of web browsing, maintain state by storing data that persists in external files. Additionally, by overwriting YAML files, we can modify the values inside of our stored Ruby objects. …

About

Jordan Moore

Software Engineer | jordanmoore.io

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store