Tag: Java

Leetcode 11 Container With Most Water
Problem 11 Container With Most Water Given n nonnegative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with xaxis forms…

Leetcode 117 Populating Next Right Pointers in Each Node II
Problem 117 Populating Next Right Pointers in Each Node II Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant extra space. For example, Given the following…

Leetcode 75 Sort Colors
Problem 75 Sort Colors Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color…

Leetcode 22 Generate Parentheses
Problem 22 Generate Parentheses Given n pairs of parentheses, write a function to generate all combinations of wellformed parentheses. For example, given n = 3, a solution set is: "((()))", "(()())", "(())()", "()(())", "()()()" Many people say it is a easy problem, but I do not think so. As the idea is easy, but writing it…

Leetcode 21 Merge Two Sorted Lists
Problem 21 Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Not a hard one. But I spend a lot of time on this, cause I misunderstand…