I have a question about the right shift operator difference between >>> and >>


  • 1
    H

    If I use >>> it will pass, but if I use >>, it will time exceed.

    Why the performance has so much difference?


  • 0
    R

    Internally the shifts work on the same mechanism with one difference ">>>" does not preserve sign i.e. MSB bit even if it is "1" using ">>>" will add a "0" at MSB, whereas ">>" preserves sign, i.e. MSB now remains "1" after shift.

    If you paste your code we could debug it, maybe it's getting stuck in some kind of internal loop.


Log in to reply
 

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