code segments for leetcode