Skip to content

Commit a4fd82e

Browse files
authored
Create reverse-prefix-of-word.cpp
1 parent f248122 commit a4fd82e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

C++/reverse-prefix-of-word.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
string reversePrefix(string word, char ch) {
7+
reverse(begin(word), begin(word) + 1 + word.find(ch));
8+
return word;
9+
}
10+
};

0 commit comments

Comments
 (0)