[Solved] 'ascii' codec can't encode character u'\u2212' in position 29: ordinal not in range(128)

  • 8

    I ran into this issue when trying the test case provided on the question, if you're like me where you usually copy paste the example as a test case and then clicking run code, you'll run into this.

    Firstly u\u2212 is a Minus sign in Unicode.

    Turns out the example case used Unicode minus signs.

    Notice how the example, [−2,1,−3,4,−1,2,1,−5,4] differs with [-2,1,-3,4,-1,2,1,-5,4], the signs are longer.

    Posting this here in hopes of helping people figure it out since I thought it was something wrong with my code.

Log in to reply

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