Container With Most Water

Description

Given n non-negative 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 x-axis forms a container, such that the container contains the most water. Note: You may not slant the container and n is at least 2.

给出n个点,它们与X轴有n条垂线,每两条垂线与X轴形成的U型容器,找出最大“容积”(面积)

Read More

Trapping Rain Water

Description

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how >much water it is able to trap after raining.

For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6.

palindromic The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. Thanks Marcos for contributing this image!

Read More

Longest Substring Without Repeating Characters

Description

Given a string, find the length of the longest substring without repeating characters.

Given “abcabcbb”, the answer is “abc”, which the length is 3.

Given “bbbbb”, the answer is “b”, with the length of 1.

Given “pwwkew”, the answer is “wke”, with the length of 3. Note that the answer must be a substring, “pwke” is a subsequence and not a substring.

在给定字符串中找出无重复字符的最长子串。

Read More

Author's picture

SelFree

城市永远年轻,而我们终将老去

Programer

ChengDu·China
-