All Posts

Leetcode 977: Squares of a Sorted Array

Given an integer array nums sorted in non-decreasing order, return an array of the squares of each element, sorted in non-decreasing order.

Leetcode 1023: Camelcase Matching

You are given a list of query strings and a pattern. A query string matches the pattern if you can insert lowercase English letters into the pattern such that it becomes the query string. Each character from the pattern must be placed in order without changing its relative positions, and you may not add any characters that are not in the pattern.

Leetcode 1040: Moving Stones Until Consecutive II

You are given a list of stones placed at different positions along the X-axis. A stone is considered an endpoint if it has the smallest or largest position. In one move, you can pick an endpoint stone and move it to any unoccupied position. The game ends when no more moves are possible, which occurs when the stones are in three consecutive positions. The goal is to find the minimum and maximum number of moves that can be made to achieve this configuration.

Leetcode 1048: Longest String Chain

You are given an array of words, where each word consists of lowercase English letters. A wordA is considered a predecessor of wordB if you can insert exactly one letter anywhere in wordA without changing the order of the other characters to make it equal to wordB. A word chain is a sequence of words such that each word is a predecessor of the next one. Your task is to find the length of the longest word chain that can be formed from the given list of words.

Leetcode 1237: Find Positive Integer Solution for a Given Equation

You are given a callable function f(x, y) with a hidden formula and a target value z. Your task is to find all pairs of positive integers x and y such that f(x, y) == z. The function is monotonically increasing, meaning: f(x, y) < f(x + 1, y) and f(x, y) < f(x, y + 1). Return a list of all such pairs. If no valid pairs are found, return an empty list.

Leetcode 1471: The k Strongest Values in an Array

Given an array of integers and an integer k, you need to find the strongest k elements in the array. The strength of each element is determined by how far it is from the median of the array. If two elements are equidistant from the median, the larger element is considered stronger. Return the k strongest elements in any order.