Skip to content

Practice Can Convert String in K Moves

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1540
LeetCode Problem

Can Convert String in K Moves

Problem Statement

Determine whether s can become t using at most k numbered moves. During move i, either do nothing or choose one position never chosen before and shift its letter forward i times in the alphabet, wrapping z to a. Every position may be selected at most once, and moves are numbered from 1 through k. Return whether the transformation is possible.

Source: Can Convert String in K Moves on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "input", t = "ouput", k = 9
Output
true

# Example 2

Input
s = "abc", t = "bcd", k = 10
Output
false

# Example 3

Input
s = "aab", t = "bbb", k = 27
Output
true

Constraints

1 <= s.length, t.length <= 10^5
0 <= k <= 10^9
s, t contain only lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Can Convert String in K Moves.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.