The Jump Game is a popular interview problem and a classic example of applying a Greedy Algorithm. It appears frequently…
Browsing: Medium
The N Meetings in One Room problem is a classic example of the Greedy Algorithm. It focuses on scheduling tasks…
The Fractional Knapsack problem is one of the most famous problems in the Greedy Algorithm category. It is widely asked…
The problem “Maximum Points You Can Obtain from Cards” asks you to pick exactly k cards from either the start or the end of the array cardPoints to maximize the total points. The key insight is that if…
The problem “Number of Substrings Containing All Three Characters” asks: given a string s consisting only of the characters ‘a’, ‘b’, and ‘c’, count how many substrings contain at least one of each of…
The problem “Longest Repeating Character Replacement” asks for the length of the longest substring that can be converted into a string of…
The problem “Fruit Into Baskets” asks for the length of the longest contiguous subarray that contains at most two distinct fruit types. Think…
The problem “Max Consecutive Ones III” asks for the length of the longest subarray containing only 1s after flipping at most k zeros to 1s. This is a classic sliding window problem where we maintain…
The problem “Longest Substring Without Repeating Characters” asks for the length of the longest substring in a string s that contains no duplicate characters. A straightforward brute force approach…
We are given an array asteroids of integers representing asteroids in a row. The indices of the asteriod in the array represent…