Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 324 Bytes

File metadata and controls

16 lines (12 loc) · 324 Bytes

brutal force

There will also be negative number: deal with the “-” first

The String only contains “-” and numbers, because this is an integer.

There are 4 cases:

    • and +: subtract
    • and +: sum
    • and -: sum
    • and -: subtract

subtract: larger - smaller
sum: no matter

time: O(n)
space: O(1)