Solutions to leetcode algorithms