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.
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. …
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.
First, one needs to break down the problem thoroughly. Let’s read the description and explore any questions that arise from it. …
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…
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.
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. …
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.
Unlike class-based languages, like
Every object has a private property which holds a link to another object known as its prototype. …
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. …
This makes the job of a developer very easy:
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. …
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.
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. …