leetcode:assign variable correctly