Codeforces Round 949 (Div. 2) C. Turtle and an Incomplete Sequence
1684. Count the Number of Consistent Strings
You are given a string
allowed
consisting of distinct characters and an array of stringswords
. A string is consistent if all characters in the string appear in the stringallowed
.Return the number of consistent strings in the array
words
.
3283. Maximum Number of Moves to Kill All Pawns
There is a
50 x 50
chessboard with one knight and some pawns on it. You are given two integerskx
andky
where(kx, ky)
denotes the position of the knight, and a 2D arraypositions
wherepositions[i] = [xi, yi]
denotes the position of the pawns on the chessboard.Alice and Bob play a turn-based game, where Alice goes first. In each player’s turn:
- The player selects a pawn that still exists on the board and captures it with the knight in the fewest possible moves. Note that the player can select any pawn, it might not be one that can be captured in the least number of moves.
- In the process of capturing the selected pawn, the knight may pass other pawns without capturing them. Only the selected pawn can be captured in this turn.
Alice is trying to maximize the sum of the number of moves made by both players until there are no more pawns on the board, whereas Bob tries to minimize them.
Return the maximum total number of moves made during the game that Alice can achieve, assuming both players play optimally.
Note that in one move, a chess knight has eight possible positions it can move to, as illustrated below. Each move is two cells in a cardinal direction, then one cell in an orthogonal direction.
3282. Reach End of Array With Max Score
You are given an integer array
nums
of lengthn
.Your goal is to start at index
0
and reach indexn - 1
. You can only jump to indices greater than your current index.The score for a jump from index
i
to indexj
is calculated as(j - i) * nums[i]
.Return the maximum possible total score by the time you reach the last index.