my solution for leetcode executed in java accepted by OJ