leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2000.cpp (361B)


0 class Solution { 1 public: 2 string reversePrefix(string word, char ch) const { 3 const int n = size(word); 4 int i; 5 6 for (i = 0; i < n; i++) { 7 if (word[i] == ch) break; 8 } 9 10 if (i == n) return word; 11 12 int j = 0; 13 while (j < i) 14 swap(word[i--], word[j++]); 15 16 return word; 17 } 18 };