[LeetCode] Shift Distance Between Two Strings

3361. Shift Distance Between Two Strings

You are given two strings s and t of the same length, and two integer arrays nextCost and previousCost.

In one operation, you can pick any index i of s, and perform either one of the following actions:

  • Shift s[i] to the next letter in the alphabet. If s[i] == 'z', you should replace it with 'a'. This operation costs nextCost[j] where j is the index of s[i] in the alphabet.
  • Shift s[i] to the previous letter in the alphabet. If s[i] == 'a', you should replace it with 'z'. This operation costs previousCost[j] where j is the index of s[i] in the alphabet.

The shift distance is the minimum total cost of operations required to transform s into t.

Return the shift distance from s to t.

Read more
[LeetCode] Stone Removal Game

3360. Stone Removal Game

Alice and Bob are playing a game where they take turns removing stones from a pile, with Alice going first.

  • Alice starts by removing exactly 10 stones on her first turn.
  • For each subsequent turn, each player removes exactly 1 fewer stone than the previous opponent.

The player who cannot make a move loses the game.

Given a positive integer n, return true if Alice wins the game and false otherwise.

Read more
[AtCoder] F - Double SumRead more
[AtCoder] A - 01 Matrix AgainRead more
[AtCoder] B - Simple Math 4Read more
[AtCoder] E - Toward 0Read more
[AtCoder] E - Weighted Tic-Tac-ToeRead more
[AtCoder] E - Minimize Sum of DistancesRead more
[AtCoder] F - Exchange GameRead more
[AtCoder] G - Another Shuffle WindowRead more