A fancy string is a string where no three consecutive characters are equal.

Given a string s, delete the minimum possible number of characters from s to make it fancy.

Return the final string after the deletion. It can be shown that the answer will always be unique.

&nbsp;
Example 1:

Input: s = "leeetcode"
Output: "leetcode"
Explanation:
Remove an 'e' from the first group of 'e's to create "leetcode".
No three consecutive characters are equal, so return "leetcode".


Example 2:

Input: s = "aaabaaaa"
Output: "aabaa"
Explanation:
Remove an 'a' from the first group of 'a's to create "aabaaaa".
Remove two 'a's from the second group of 'a's to create "aabaa".
No three consecutive characters are equal, so return "aabaa".


Example 3:

Input: s = "aab"
Output: "aab"
Explanation: No three consecutive characters are equal, so return "aab".


&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 105
	s consists only of lowercase English letters.


class Solution:
    def makeFancyString(self, s: str) -> str:
        if len(s) < 3:
            return s
        ans = ''
        ans += s[0]
        ans += s[1]
        for i in range(2,len(s)):
            if s[i] != ans[-1] or s[i] != ans[-2]:
                ans += s[i]
        return ans
class Solution {
    public String makeFancyString(String s) {
        char prev = s.charAt (0);
        int freq = 1;
        StringBuilder res = new StringBuilder ();
        res.append (s.charAt (0));
        for (int i = 1; i < s.length (); i++) {
            if (s.charAt (i) == prev)
                freq++;
            else {
                prev = s.charAt (i);
                freq = 1;
            }
            if (freq < 3)
                res.append (s.charAt (i));
        }
        return res.toString ();
    }
}
class Solution {
public:
    string makeFancyString(string s) {
        int cnt=1;
        string ans="";    ans.push_back(s[0]);
		
        for(int i=1;i<s.length();++i) {
            cnt=s[i]==s[i-1]? cnt+1:1;

            if(cnt<3) {
                ans.push_back(s[i]);
            }
        }
        return ans;

    }
};
};
var makeFancyString = function(s) {
    let res = '';
    let currCount = 0;
    
    for (let i = 0; i < s.length; i++) {
        if (currCount === 2 && s[i] === s[i - 1]) continue;
        
        else if (s[i] === s[i - 1]) {
            currCount++;
            res += s[i];
        }
        
        else {
            currCount = 1;
            res += s[i]
        }
    }
    
    return res;
};
Delete Characters to Make Fancy String