LeetCode - Blind 75 - Insert Interval

The problem You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represents the start and the end of the ith interval, and intervals is sorted in ascending order by starti. You are also given an interval newInterval = [start, end] that represents the start and end of another interval. Insert newInterval into intervals such that intervals is still sorted in ascending order by starti and intervals still does not have any overlapping intervals (merge overlapping intervals if necessary). ...

April 15, 2025 · 4 min · Dmytro Chumakov

LeetCode - Blind 75 - Jump Game

The problem You are given an integer array nums. You are initially positioned at the array’s first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false otherwise. Examples Input: nums = [2,3,1,1,4] Output: true Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index. Input: nums = [3,2,1,0,4] Output: false Explanation: You will always arrive at index 3 no matter what. Its maximum jump length is 0, which makes it impossible to reach the last index. Constraints 1 <= nums.length <= 10⁴ 0 <= nums[i] <= 10⁵ Explanation From the description of the problem, we learn that we start from the start index, and for every element in the array, the number at the position represents the max jump length that we can perform at every single position. Basically, this means for input with nums = [2,3,1,1,4] ...

April 13, 2025 · 5 min · Dmytro Chumakov

LeetCode - Blind 75 - Maximum Subarray

The problem Given an integer array nums, find the subarray with the largest sum, and return its sum. A subarray is a contiguous non-empty sequence of elements within an array. Examples Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: The subarray [4,-1,2,1] has the largest sum 6. Input: nums = [1] Output: 1 Explanation: The subarray [1] has the largest sum 1. Input: nums = [5,4,-1,7,8] Output: 23 Explanation: The subarray [5,4,-1,7,8] has the largest sum 23. Constraints 1 <= nums.length <= 10⁵ -10⁴ <= nums[i] <= 10⁴ Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. ...

April 10, 2025 · 3 min · Dmytro Chumakov

LeetCode - Blind 75 - Longest Common Subsequence

The problem Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. For example, ”ace” is a subsequence of ”abcde”. A common subsequence of two strings is a subsequence that is common to both strings. ...

April 8, 2025 · 7 min · Dmytro Chumakov

LeetCode - Blind 75 - Unique Paths

The problem There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time. Given the two integers m and n, return the number of possible unique paths that the robot can take to reach the bottom-right corner. ...

April 5, 2025 · 4 min · Dmytro Chumakov