Given a 0-indexed string
wordand a characterch, reverse the segment ofwordthat starts at index0and ends at the index of the first occurrence ofch(inclusive). If the characterchdoes not exist inword, do nothing.
- For example, if
word = "abcdefd"andch = "d", then you should reverse the segment that starts at0and ends at3(inclusive). The resulting string will be"dcbaefd".Return the resulting string.
1 | class Solution { |