All Posts

Leetcode 1893: Check if All the Integers in a Range Are Covered

You are given a list of integer ranges and two integers, left and right. Each range is represented by a pair of integers [start, end]. You need to determine if all integers from left to right (inclusive) are covered by at least one of these ranges. An integer x is considered covered by a range [start, end] if start <= x <= end.

Leetcode 1915: Number of Wonderful Substrings

A string is considered wonderful if at most one letter appears an odd number of times. Given a string word consisting of the first ten lowercase English letters (‘a’ through ‘j’), return the total number of wonderful non-empty substrings in the string word. If the same substring appears multiple times, each occurrence should be counted separately.

Leetcode 1930: Unique Length-3 Palindromic Subsequences

You are given a string s, and you need to return the number of unique palindromic subsequences of length 3 that are subsequences of s.

Leetcode 1943: Describe the Painting

You are given a painting represented by a number line. Multiple overlapping segments are painted with different colors. Your task is to return a minimal set of non-overlapping painted segments, where each segment represents a portion of the painting with a unique set of mixed colors. Each segment should be represented by the sum of the colors in the mixed sets.

Leetcode 1991: Find the Middle Index in Array

Given a 0-indexed integer array ’nums’, find the leftmost index where the sum of elements to the left of that index is equal to the sum of elements to the right of that index. If such an index exists, return the smallest such index, otherwise return -1. The sum of the elements before the first index is considered 0, and similarly, the sum of elements after the last index is also 0.

Leetcode 2017: Grid Game

You are given a 2D grid of size 2 x n, where each cell contains points. Two robots play a game where they start at (0, 0) and aim to reach (1, n-1). The first robot moves first, collecting points along its path. Then, the second robot moves, trying to maximize the points it collects. The task is to find the number of points collected by the second robot if both play optimally.