LeetCode 875: Koko Eating Bananas

Today, let’s look at LeetCode problem 875: Koko Eating Bananas. The instructions are as follows: Koko loves to eat bananas. There are n piles of bananas, the \(i\)-th pile has piles[i] bananas. The guards have gone and will come back in h hours. Koko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of bananas and eats k bananas from that pile. If the pile has less than k bananas, she eats all of them instead and will not eat any more bananas during this hour. Koko likes to eat slowly but still wants to finish eating all the bananas before the guards return. Return the minimum integer k such that she can eat all the bananas within h hours. ...

December 28, 2025 · 4 min · David Nabergoj

LeetCode 72: Edit distance

Today, let’s look at LeetCode problem 72: Edit distance. The instructions are as follows: Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: Insert a character Delete a character Replace a character Let’s dive in! The Wagner-Fischer algorithm There are several types of edit distance. This LeetCode problem defines it as the Levenshtein distance. The most common algorithm to compute it is the Wagner-Fischer algorithm. ...

December 27, 2025 · 5 min · David Nabergoj

LeetCode 746: Min Cost Climbing Stairs

Today, let’s look at LeetCode problem 746: Min Cost Climbing Stairs. The instructions are as follows: You are given an integer array cost where cost[i] is the cost of \(i\)-th step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with index 1. Return the minimum cost to reach the top of the floor. ...

December 27, 2025 · 2 min · David Nabergoj

LeetCode 435: Non-overlapping Intervals

Today, let’s look at LeetCode problem 435: Non-overlapping intervals. The instructions are as follows: Given an array of intervals intervals where intervals[i] = [start_i, end_i], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Note that intervals which only touch at a point are non-overlapping. For example, [1, 2] and [2, 3] are non-overlapping. Let’s dive in! Interval scheduling reformulation Interval scheduling is a class of problems that involve a set of tasks, represented by their start and end times. The interval scheduling maximization problem (ISMP) is about finding the largest set of non-overlapping tasks. This is highly related to our interval removal problem. In fact, the following statements are equivalent: ...

December 26, 2025 · 3 min · David Nabergoj

LeetCode 399: Evaluate Division

Hi, everyone! Today, we’ll be looking at LeetCode problem 399. In this problem, we are given a bunch of reference equations of the form \(a_i / b_i = c_i\) for \(i = 1 , \dots, n\). The symbols \(a_i, b_i\) are given as strings, while \(c_i\) are given as floating point numbers. We’re then asked to compute the value of a query equation \(q_1 / q_2\). If \(q_1 / q_2\) is one of the reference equations, we can return that value. Otherwise, we can follow a kind of chain-rule strategy. Suppose we are given "a" / "b" with value 2.0 and "b" / "c" with value 3.0, then we can compute "a" / "c" by the product: "a" / "c" = "a" / "b" * "b" / "c", which is equal to 2.0 * 3.0 = 6.0. If there’s no way to find a solution, we return -1. ...

December 25, 2025 · 6 min · David Nabergoj