space complexity improved to be constant
code style optimization
code style optimization