https://leetcode.com/problems/reverse-string-ii/


Success

___

```python
class Solution:
    def reverseStr(self, s: str, k: int) -> str:
        #2023/01/30 07:34
        if k == 1:
            return s
        
        result = []
        temp_list = []
        reverse_flag = False
        for index, char in enumerate(s):
            signal = ((index//k)%k)
            if signal == 0 or signal%2 == 0:
                if reverse_flag == False:
                    result += temp_list.copy()
                    temp_list = []
                temp_list.append(char)
                reverse_flag = True
            else:
                if reverse_flag == True:
                    result += list(reversed(temp_list.copy()))
                    temp_list = []
                temp_list.append(char)
                reverse_flag = False
            #print(signal, reverse_flag, index%k)

        if len(temp_list) != 0:
            if reverse_flag == False:
                result += temp_list.copy()
                temp_list = []
            if reverse_flag == True:
                result += list(reversed(temp_list.copy()))
                temp_list = []

        return "".join(result)
        #2023/01/30 07:44, debug until 8:14
```
