Practice Maximum Manhattan Distance After K Changes
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Starting at (0, 0), follow s in order, where N, S, E, and W each move one unit in the named direction. You may replace at most k characters with any of those directions. Return the greatest Manhattan distance |x| + |y| from the origin attainable at any point during the modified walk, not only at its end.
Source: Maximum Manhattan Distance After K Changes on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "NWSE", k = 1
3
# Example 2
s = "NSWWEW", k = 3
6
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Manhattan Distance After K Changes.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.