Given a string ans a specified character, reverse the prefix that is ended with the specified character.
Intuition
Simulate the process.
Approach
find the first occurrence of the specified character, then reverse the prefix.
Complexity
- $$O(n)$$
- $$O(1)$$
Code
|
|