Tap here to switch tabs
Problem
Submissions

Problem: Reverse String Prefix

Reverse String Prefix gives you a string and an integer k, then asks you to return a new string with its first k characters reversed while every remaining character stays in place.

Statement

Given a string s and an integer k, reverse the prefix of s consisting of the first k characters while leaving the rest of the string unchanged. Return the resulting string.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s consists of lowercase English letters.

  • 1≤1 \leq k ≤\leq s.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Reverse String Prefix

Reverse String Prefix gives you a string and an integer k, then asks you to return a new string with its first k characters reversed while every remaining character stays in place.

Statement

Given a string s and an integer k, reverse the prefix of s consisting of the first k characters while leaving the rest of the string unchanged. Return the resulting string.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s consists of lowercase English letters.

  • 1≤1 \leq k ≤\leq s.length