1 line Python solution


  • 0

    Use zip and list comprehension:

        return [s[0:i[0]] + '--' + s[i[0] + 2:] for i in zip(range(len(s) - 1), s[1:], s[:-1]) if i[1] + i[2] == '++']

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.