2663. Lexicographically Smallest Beautiful String
A string is beautiful if:
- It consists of the first
kletters of the English lowercase alphabet.- It does not contain any substring of length
2or more which is a palindrome.You are given a beautiful string
sof lengthnand a positive integerk.Return the lexicographically smallest string of length
n, which is larger thansand is beautiful. If there is no such string, return an empty string.A string
ais lexicographically larger than a stringb(of the same length) if in the first position whereaandbdiffer,ahas a character strictly larger than the corresponding character inb.
- For example,
"abcd"is lexicographically larger than"abcc"because the first position they differ is at the fourth character, anddis greater thanc.
2662. Minimum Cost of a Path With Special Roads
You are given an array
startwherestart = [startX, startY]represents your initial position(startX, startY)in a 2D space. You are also given the arraytargetwheretarget = [targetX, targetY]represents your target position(targetX, targetY).The cost of going from a position
(x1, y1)to any other position in the space(x2, y2)is|x2 - x1| + |y2 - y1|.There are also some special roads. You are given a 2D array
specialRoadswherespecialRoads[i] = [x1i, y1i, x2i, y2i, costi]indicates that theithspecial road can take you from(x1i, y1i)to(x2i, y2i)with a cost equal tocosti. You can use each special road any number of times.Return the minimum cost required to go from
(startX, startY)to(targetX, targetY).
2661. First Completely Painted Row or Column
You are given a 0-indexed integer array
arr, and anm x ninteger matrixmat.arrandmatboth contain all the integers in the range[1, m * n].Go through each index
iinarrstarting from index0and paint the cell inmatcontaining the integerarr[i].Return the smallest index
iat which either a row or a column will be completely painted inmat.
2660. Determine the Winner of a Bowling Game
You are given two 0-indexed integer arrays
player1andplayer2, that represent the number of pins that player 1 and player 2 hit in a bowling game, respectively.The bowling game consists of
nturns, and the number of pins in each turn is exactly10.Assume a player hit
xipins in theithturn. The value of theithturn for the player is:
2xiif the player hit10pins in any of the previous two turns.- Otherwise, It is
xi.The score of the player is the sum of the values of their
nturns.Return
1if the score of player 1 is more than the score of player 2,2if the score of player 2 is more than the score of player 1, and0in case of a draw.
You are given an integer array
numscontaining distinct numbers, and you can perform the following operations until the array is empty:
- If the first element has the smallest value, remove it
- Otherwise, put the first element at the end of the array.
Return an integer denoting the number of operations it takes to make
numsempty.
2658. Maximum Number of Fish in a Grid
You are given a 0-indexed 2D matrix
gridof sizem x n, where(r, c)represents:
- A land cell if
grid[r][c] = 0, or- A water cell containing
grid[r][c]fish, ifgrid[r][c] > 0.A fisher can start at any water cell
(r, c)and can do the following operations any number of times:
- Catch all the fish at cell
(r, c), or- Move to any adjacent water cell.
Return the maximum number of fish the fisher can catch if he chooses his starting cell optimally, or
0if no water cell exists.An adjacent cell of the cell
(r, c), is one of the cells(r, c + 1),(r, c - 1),(r + 1, c)or(r - 1, c)if it exists.
2657. Find the Prefix Common Array of Two Arrays
You are given two 0-indexed integer permutations
AandBof lengthn.A prefix common array of
AandBis an arrayCsuch thatC[i]is equal to the count of numbers that are present at or before the indexiin bothAandB.Return the prefix common array of
AandB.A sequence of
nintegers is called a permutation if it contains all integers from1tonexactly once.