You are tasked with shipping packages using a ship with a limited weight capacity. Each package has a given weight and must be shipped in order within a specified number of days. Your objective is to determine the minimum weight capacity of the ship that allows all the packages to be shipped within the given days, without exceeding the ship’s weight capacity on any single day.
Given an array of integers, you need to return the length of the longest subsequence where the difference between consecutive elements is constant. A subsequence is derived by deleting some elements without changing the order of the remaining elements. A sequence is considered arithmetic if the difference between consecutive elements remains the same.
Define a function f(s) as the frequency of the lexicographically smallest character in a non-empty string s. For example, for s = 'abc', f(s) = 1 because the smallest character is 'a', appearing once. Given an array of strings queries and another array words, return an array where each entry corresponds to the number of strings in words where f(W) is greater than f(queries[i]) for a given i.
An ugly number is a positive integer that is divisible by at least one of the integers a, b, or c. Your task is to return the nth ugly number in the sequence formed by the integers divisible by a, b, or c.
You are given two strings s and t of the same length, and an integer maxCost. You want to change string s to string t. The cost of changing the ith character of s to the ith character of t is the absolute difference between their ASCII values. Your task is to find the maximum length of a substring of s that can be changed to match the corresponding substring of t, with the total cost not exceeding maxCost.