Reverse String Prefix
You are given a string s and an integer k.
Reverse the first k characters of s and return the resulting string.
Example 1
Input
s = "abcd", k = 2Output
"bacd"The first
k = 2 characters "ab" are reversed to "ba", so the final resulting string is "bacd".Example 2
Input
s = "xyz", k = 3Output
"zyx"The first
k = 3 characters "xyz" are reversed to "zyx", so the final resulting string is "zyx".Constraints
- 1 <= s.length <= 100
- s consists of lowercase English letters.
- 1 <= k <= s.length