FastPrepFastPrep
Problem Brief

Replace Every Nth Consonant

INTERNOA

Note ->> See the Image Source section at the very bottom of the page for the original problem statement and etc.. 🐰🐰

Given a string message and an integer n, your task is to replace every nth consonant with the next consonant in alphabetical order, ensuring the case remains consistent (e.g., 'b' becomes 'c', 'x' becomes 'y', and 'Z' becomes 'B'). The consonants follow this order: 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', and if the consonant is 'z' or 'Z', it wraps around to 'b' or 'B'. While your solution doesn't need to be the most efficient, it should still run smoothly with a time complexity no worse than O(message.length^2).

🫧𓇼Credit to Charlotte𓏲*ੈ✩‧₊˚🎐

1Example 1

Input
message = "CodeSignal", n = 3
Output
"CodeTignam"
Explanation
🍊

Constraints

Limits and guarantees your solution can rely on.

🍊🍊
public String metaReplaceConsonant(String message, int n) {
  // write your code here
}
Input

message

"CodeSignal"

n

3

Output

"CodeTignam"

Sign in to submit your solution.