Tap here to switch tabs
Problem
Submissions

Problem: Can Convert String in K Moves

med
30 min
Try to solve the Can Convert String in K Moves problem.

Statement

Given two strings s and t, determine whether s can be transformed into t in at most k moves.

In the iextthi^{ ext{th}} move, where 1≤i≤k1 \leq i \leq k, you can perform one of the following actions:

  • Select an index j (where 0≤j<0 \leq j < s.length) that has not been chosen in any prior move, and shift the character s[j] forward in the alphabet cyclically by ii positions (for example, shifting 'z' forward by 11 position gives 'a').

  • Skip the move and do nothing.

Return true if s can be transformed into t in at most k moves, or false otherwise.

Constraints:

  • 1≤1 \leq s.length, t.length ≤105\leq 10^5

  • 0≤0 \leq k ≤109\leq 10^9

  • s and t contain only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Can Convert String in K Moves

med
30 min
Try to solve the Can Convert String in K Moves problem.

Statement

Given two strings s and t, determine whether s can be transformed into t in at most k moves.

In the iextthi^{ ext{th}} move, where 1≤i≤k1 \leq i \leq k, you can perform one of the following actions:

  • Select an index j (where 0≤j<0 \leq j < s.length) that has not been chosen in any prior move, and shift the character s[j] forward in the alphabet cyclically by ii positions (for example, shifting 'z' forward by 11 position gives 'a').

  • Skip the move and do nothing.

Return true if s can be transformed into t in at most k moves, or false otherwise.

Constraints:

  • 1≤1 \leq s.length, t.length ≤105\leq 10^5

  • 0≤0 \leq k ≤109\leq 10^9

  • s and t contain only lowercase English letters.