Image for post
Image for post
Photo by Rachel Park

Introduction
Recently I’ve got to solve a problem on LeetCode, and decided to write this article because, even though it was not extremely hard, the whole complexity was in the precomputation of some data. Let’s have a look:

The Problem
As already mentioned, I came across this medium-difficulty problem while solving a coding challenge on LeetCode. The title is “Cout Good Meals”:

A good meal is a meal that contains exactly two different food items with a sum of deliciousness equal to a power of two.

You can pick any two different foods to make a good meal.

Given an…


Image for post
Image for post

Introduction
I’ve recently come across one of the thousands of problems that can be solved with dynamic programming techniques. I remember that, when I was trying to get my head around this topic, one of the most frustrating aspects was the ever-green Fibonacci Numbers example. It was everywhere, but I had the impression that reading over and over the same stories about overlapping subproblems and optimal substructures, always with the same example and the same images in from of my eyes wasn’t really paying off the effort. …


Image for post
Image for post

Introduction
In this article, we are going to study and solve the medium difficulty LeetCode challenge Stone Game VII. It’s a sort of extension of the previous Stone Game VI, already analyzed and solved in this previous article. Let’s get started with the problem description, the examples, the analysis of the problem, and eventually the code.

The Problem
First off, let me ctrl-c ctrl-v the problem description:

Alice and Bob take turns playing a game, with Alice starting first.

There are n stones arranged in a row. On each player's turn, they can remove either the leftmost stone or the…


Image for post
Image for post

Introduction
Throughout this article, we are going to be analyzing an interesting coding challenge that I’ve recently happened to solve. Those of you who love problem visualization as I do might end up being disappointed because this time I didn’t manage to come up with a satisfying visualization of the problem, however, I’ll try my best to run you through the thoughts that led me to the solution.

The problem
As usual, this is one of the problems that I found while brushing up my algorithmic skilled on LeetCode. This medium difficulty problem is titled “Stone Game VI”:

Alice and…


Image for post
Image for post

Introduction
In this article, we will be going through the solution to a coding challenge that I’ve recently had the pleasure to solve taking one of the LeetCode contests. Other than the solution itself, I’ll be providing an easy visualization that hopefully will make everything really simple to grasp.

The problem
I’m not going to spend much time here, let me just copy-paste the description of this problem titled “Sum of Absolute Differences in a Sorted Array

You are given an integer array nums sorted in non-decreasing order.

Build and return an integer array result with the same length as…


Image for post
Image for post

Introduction
Recently I’ve got to spend some hours thinking of a useful visualization for a problem whose key point is a pretty straightforward intuition. I am a stronger believer in visualization to help make a concept stick. That being said, I have got to be honest, am not sure if I pulled it off this time, but eventually came up with something that I liked. Let me know your thoughts.

The Problem
Let’s start with the description of this problem which has been labeled as hard by LeetCode. The title is “Minimum Initial Energy to Finish Tasks”:

You are given…


Image for post
Image for post

Introduction
In this article, we will be solving and discussing the solution to one of the problems that I have recently got to work on. I reckon that it deserves some attention, not for its complexity, but because it requires the developer to do a little analysis and precomputation on the input data to pave the way for an easy solution.

The Problem
I have recently come across this problem while brushing up my algorithmic skills by solving a coding contest on LeetCode. It is titled “Ways to Make a Fair Array” and the description states:

You are given an…


Image for post
Image for post

Introduction
In this article, we are going to be discussing an algorithm that lends itself to visualization. We will get started from a concrete problem, a code challenge that I’ve recently got to solve, trying to figure out a general approach that can be reused in many other circumstances.

The Problem
This is a medium difficulty LeetCode problem called “Split a String Into the Max Number of Unique Substrings”. The description is the following:

Given a string s, return the maximum number of unique substrings that the given string can be split into.

You can split string s into any…


Image for post
Image for post

Introduction
In this article, I’ll be trying to describe a rather common Dynamic Programming technique used to solve an interesting coding challenge taken from one of the contests that you can find on LeetCode.
As DP (Dynamic Programming) can be a tricky concept, sometimes hard to grasp, I’ve endeavored to produce some pictures which will help to get the point across.

The problem
I came across this problem while taking a LeetCode contest. The title of the problem is Best Team With No Conflicts and here below the problem description:

You are the manager of a basketball team. For the…


Image for post
Image for post

Introduction
In this article, we are going to analyze part of the fascinating Binary Tree world. The applications of this data structure are limitless, and even though it might be a bit scary at first, I promise that with the help of some pictures and visualizations, we will be getting acquainted with it, and hopefully learning something new.

As usual, I like to start from a practical problem, why not the coding challenge which got me to write this post? So let’s kick this off.

The Problem While practicing coding on LeetCode, I came across the Path In Zigzag Labelled…

Federico Feresini

Software Engineer

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