1464. Maximum Product of Two Elements in an Array
Given the array of integers
nums, you will choose two different indicesiandjof that array. Return the maximum value of(nums[i]-1)*(nums[j]-1).
2912. Number of Ways to Reach Destination in the Grid
You are given two integers
nandmwhich represent the size of a 1-indexed grid. You are also given an integerk, a 1-indexed integer arraysourceand a 1-indexed integer arraydest, wheresourceanddestare in the form[x, y]representing a cell on the given grid.You can move through the grid in the following way:
- You can go from cell
[x1, y1]to cell[x2, y2]if eitherx1 == x2ory1 == y2.- Note that you can’t move to the cell you are already in e.g.
x1 == x2andy1 == y2.Return the number of ways you can reach
destfromsourceby moving through the grid exactlyktimes.Since the answer may be very large, return it modulo
109 + 7.
2921. Maximum Profitable Triplets With Increasing Prices II
Given the 0-indexed arrays
pricesandprofitsof lengthn. There arenitems in an store where theithitem has a price ofprices[i]and a profit ofprofits[i].We have to pick three items with the following condition:
prices[i] < prices[j] < prices[k]wherei < j < k.If we pick items with indices
i,jandksatisfying the above condition, the profit would beprofits[i] + profits[j] + profits[k].Return the maximum profit we can get, and
-1if it’s not possible to pick three items with the given condition.