shlogg · Early preview
Md Ariful Haque @mah-shamim

Reverse Prefix Of Word In 60 Characters

Reverse prefix of word: given string and char, reverse segment from start to first occurrence of char (inclusive). If char not found, return original string. Example: "abcdefd" with "d", result is "dcbaefd".

2000. Reverse Prefix of Word
Easy
Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.

For example, if word = "abcdefd" and ch = "d", then you should reverse the segment that starts at 0 and ends at 3 (inclusive). The resulting string will be "dcbaefd".

Return t*he resulting string*.
Example 1:

Input: word = "abcdefd", ch = "d"
Output: "dcbaefd"
Explanation: The first occurrence of "d" is at index 3.\
Reverse the part of wor...