2473. Minimum Cost to Buy Apples
You are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads, where roads[i] = [ai, bi, costi] indicates that there is a bidirectional road between cities ai and bi with a cost of traveling equal to costi.
You can buy apples in any city you want, but some cities have different costs to buy apples. You are given the array appleCost where appleCost[i] is the cost of buying one apple from city i.
You start at some city, traverse through various roads, and eventually buy exactly one apple from any city. After you buy that apple, you have to return back to the city you started at, but now the cost of all the roads will be multiplied by a given factor k.
Given the integer k, return an array answer of size n where answer[i] is the minimum total cost to buy an apple if you start at city i.
2464. Minimum Subarrays in a Valid Split
You are given an integer array nums.
Splitting of an integer array nums into subarrays is valid if:
- the greatest common divisor of the first and last elements of each subarray is greater than 1, and
- each element of nums belongs to exactly one subarray.
Return the minimum number of subarrays in a valid subarray splitting of nums. If a valid subarray splitting is not possible, return -1.
Note that:
- The greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.
- A subarray is a contiguous non-empty part of an array.
2489. Number of Substrings With Fixed Ratio
You are given a binary string s, and two integers num1 and num2. num1 and num2 are coprime numbers.
A ratio substring is a substring of s where the ratio between the number of 0’s and the number of 1’s in the substring is exactly num1 : num2.
- For example, if num1 = 2 and num2 = 3, then “01011” and “1110000111” are ratio substrings, while “11000” is not.
Return the number of non-empty ratio substrings of s.
Note that:
- A substring is a contiguous sequence of characters within a string.
- Two values x and y are coprime if gcd(x, y) == 1 where gcd(x, y) is the greatest common divisor of x and y.
2495. Number of Subarrays Having Even Product
Given a 0-indexed integer array nums, return the number of subarrays of nums having an even product.
2505. Bitwise OR of All Subsequence Sums
Given an integer array nums, return the value of the bitwise OR of the sum of all possible subsequences in the array.
A subsequence is a sequence that can be derived from another sequence by removing zero or more elements without changing the order of the remaining elements.