What's the meaning of "without extra space"?


  • 0
    P

    A lot of method in the discuss used the temporary variables, such as "int temp" and so on. My understanding is that just use the "x" to solve the problem. Is there any algorithms to do it ?


  • -1
    M

    "without extra space" usually means with o(1) space. so if you use a temp variable you'e still using o(1) space and it is fine. But you should be more specific about the problem you're talking about.


  • 0
    P

    My misunderstanding. Thanks for a lot!!


  • 0
    P

    using a long to store the reversed integer is not using extra space. right? Just confirming, it is O(1) but the problem does not make it clear


  • 0
    S

    If I change a variable's type(eg. int to str), does it cost extra space?


Log in to reply
 

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