leetcode and uva 592