Special String Again

  • + 0 comments

    I can't quite figure out the formula in the 2nd pass

    ans += (i[1] * (i[1] + 1)) // 2
    

    How is this derived? Emprically I understand that it is correct. But I can't quite understand why.