Morris Traverse(Time O(n),Space O(1))

  • 0

    O(n) Time Complexity
    O(1) Space

    But the code seems not very clean since u need to maintain something such as
    curCount,maxCount, lastVal,curVal(cur.val)...

    you also need to do check after while loop...
    my code took me almost 70 Lines...

Log in to reply

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