Code for leetcode