https://leetcode.com/problems/delete-characters-to-make-fancy-string/



Runtime: 606 ms, faster than 12.50% of TypeScript online submissions for Delete Characters to Make Fancy String.

Memory Usage: 124.1 MB, less than 12.50% of TypeScript online submissions for Delete Characters to Make Fancy String.



```typescript
function makeFancyString(s: string): string {
    //10:22
    s = s + "+"
    let string_list = [...s]
    let result_list = []
    
    let i = 0
    let tempList = []
    while (true) {
        let value = string_list[i]
        if (tempList.length == 0) {
            tempList.push(value)
        } else {
            if (value === tempList.slice(-1)[0]) {
                tempList.push(value)
            } else {
                if (tempList.length >= 2) {
                    result_list.push(tempList.slice(-1)[0])
                    result_list.push(tempList.slice(-1)[0])
                } else if (tempList.length > 0) {
                    result_list.push(tempList.slice(-1)[0])
                }
                tempList = []
                tempList.push(value)
            }
        }
        
        if (value == "+") {
            if (tempList.length > 0) {
                if (tempList.length >= 2) {
                    result_list.push(tempList.slice(-1)[0])
                    result_list.push(tempList.slice(-1)[0])
                } else if (tempList.length > 0) {
                    result_list.push(tempList.slice(-1)[0])
                }
            }
        }
        
        i++;
        if (i > s.length - 1) { 
            break; 
        } 
    }
    return result_list.join("").slice(0, -1)
    //12:19
};

```

