2818. Apply Operations to Maximize Score
You are given an array
numsofnpositive integers and an integerk.Initially, you start with a score of
1. You have to maximize your score by applying the following operation at mostktimes:
- Choose any non-empty subarray
nums[l, ..., r]that you haven’t chosen previously.- Choose an element
xofnums[l, ..., r]with the highest prime score. If multiple such elements exist, choose the one with the smallest index.- Multiply your score by
x.Here,
nums[l, ..., r]denotes the subarray ofnumsstarting at indexland ending at the indexr, both ends being inclusive.The prime score of an integer
xis equal to the number of distinct prime factors ofx. For example, the prime score of300is3since300 = 2 * 2 * 3 * 5 * 5.Return the maximum possible score after applying at most
koperations.Since the answer may be large, return it modulo
109 + 7.
2817. Minimum Absolute Difference Between Elements With Constraint
You are given a 0-indexed integer array
numsand an integerx.Find the minimum absolute difference between two elements in the array that are at least
xindices apart.In other words, find two indices
iandjsuch thatabs(i - j) >= xandabs(nums[i] - nums[j])is minimized.Return an integer denoting the minimum absolute difference between two elements that are at least
xindices apart.