leetcode

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

1957.cpp (360B)


0 class Solution {
1 public:
2 string makeFancyString(string &s) const {
3 char prev = '\0';
4 int i = 0, cnt = 0;
6 for (const char c : s) {
7 if (c == prev)
8 cnt++;
9 else
10 prev = c, cnt = 1;
11 if (cnt <= 2) s[i++] = c;
12 }
14 s.resize(i);
15 return s;
16 }
17 };