chenf99 blog


  • 首页

  • 关于

  • 归档

  • 搜索

leetcode-084

发表于 2018-11-16 | 更新于: 2018-11-16 | 分类于 leetcode
字数统计: 1.6k 字

题目

Largest Rectangle in Histogram

Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.

Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3].

The largest rectangle is shown in the shaded area, which has area = 10 unit.

Example:

1
2
3
> Input: [2,1,5,6,2,3]
> Output: 10
>
阅读全文 »

leetcode-152

发表于 2018-11-11 | 更新于: 2018-11-11 | 分类于 leetcode
字数统计: 1.2k 字

题目

Maximum Product Subarray

Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.

Example 1:

1
2
3
4
> Input: [2,3,-2,4]
> Output: 6
> Explanation: [2,3] has the largest product 6.
>

>

Example 2:

1
2
3
4
> Input: [-2,0,-1]
> Output: 0
> Explanation: The result cannot be 2, because [-2,-1] is not a subarray.
>
阅读全文 »

leetcode-072

发表于 2018-11-04 | 更新于: 2018-11-05 | 分类于 leetcode
字数统计: 1.3k 字

题目

Edit Distance

Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.

You have the following 3 operations permitted on a word:

  1. Insert a character
  2. Delete a character
  3. Replace a character

Example 1:

1
2
3
4
5
6
7
> Input: word1 = "horse", word2 = "ros"
> Output: 3
> Explanation:
> horse -> rorse (replace 'h' with 'r')
> rorse -> rose (remove 'r')
> rose -> ros (remove 'e')
>

>

Example 2:

1
2
3
4
5
6
7
8
9
> Input: word1 = "intention", word2 = "execution"
> Output: 5
> Explanation:
> intention -> inention (remove 't')
> inention -> enention (replace 'i' with 'e')
> enention -> exention (replace 'n' with 'x')
> exention -> exection (replace 'n' with 'c')
> exection -> execution (insert 'u')
>
阅读全文 »
1…456…10
Chenf99

Chenf99

30 日志
6 分类
10 标签
© 2019 Chenf99
总访客数: 总访问量:
本站共计64.3k字