Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0f258bc

Browse files
authored
Added description tasks 11-13.
1 parent 4d96d9d commit 0f258bc

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
11\. Container With Most Water
2+
3+
Medium
4+
5+
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 the line `i` is at `(i, ai)` and `(i, 0)`. Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
6+
7+
**Notice** that you may not slant the container.
8+
9+
**Example 1:**
10+
11+
![](https://s3-lc-upload.s3.amazonaws.com/uploads/2018/07/17/question_11.jpg)
12+
13+
**Input:** height = \[1,8,6,2,5,4,8,3,7\]
14+
15+
**Output:** 49
16+
17+
**Explanation:** The above vertical lines are represented by array \[1,8,6,2,5,4,8,3,7\]. In this case, the max area of water (blue section) the container can contain is 49.
18+
19+
**Example 2:**
20+
21+
**Input:** height = \[1,1\]
22+
23+
**Output:** 1
24+
25+
**Example 3:**
26+
27+
**Input:** height = \[4,3,2,1,4\]
28+
29+
**Output:** 16
30+
31+
**Example 4:**
32+
33+
**Input:** height = \[1,2,1\]
34+
35+
**Output:** 2
36+
37+
**Constraints:**
38+
39+
* `n == height.length`
40+
* `2 <= n <= 105`
41+
* `0 <= height[i] <= 104`
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
12\. Integer to Roman
2+
3+
Medium
4+
5+
Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`.
6+
7+
Symbol Value
8+
I 1
9+
V 5
10+
X 10
11+
L 50
12+
C 100
13+
D 500
14+
M 1000
15+
16+
For example, `2` is written as `II` in Roman numeral, just two one's added together. `12` is written as `XII`, which is simply `X + II`. The number `27` is written as `XXVII`, which is `XX + V + II`.
17+
18+
Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not `IIII`. Instead, the number four is written as `IV`. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as `IX`. There are six instances where subtraction is used:
19+
20+
* `I` can be placed before `V` (5) and `X` (10) to make 4 and 9.
21+
* `X` can be placed before `L` (50) and `C` (100) to make 40 and 90.
22+
* `C` can be placed before `D` (500) and `M` (1000) to make 400 and 900.
23+
24+
Given an integer, convert it to a roman numeral.
25+
26+
**Example 1:**
27+
28+
**Input:** num = 3
29+
30+
**Output:** "III"
31+
32+
**Example 2:**
33+
34+
**Input:** num = 4
35+
36+
**Output:** "IV"
37+
38+
**Example 3:**
39+
40+
**Input:** num = 9
41+
42+
**Output:** "IX"
43+
44+
**Example 4:**
45+
46+
**Input:** num = 58
47+
48+
**Output:** "LVIII"
49+
50+
**Explanation:** L = 50, V = 5, III = 3.
51+
52+
**Example 5:**
53+
54+
**Input:** num = 1994
55+
56+
**Output:** "MCMXCIV"
57+
58+
**Explanation:** M = 1000, CM = 900, XC = 90 and IV = 4.
59+
60+
**Constraints:**
61+
62+
* `1 <= num <= 3999`
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
13\. Roman to Integer
2+
3+
Easy
4+
5+
Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`.
6+
7+
Symbol Value
8+
I 1
9+
V 5
10+
X 10
11+
L 50
12+
C 100
13+
D 500
14+
M 1000
15+
16+
For example, `2` is written as `II` in Roman numeral, just two one's added together. `12` is written as `XII`, which is simply `X + II`. The number `27` is written as `XXVII`, which is `XX + V + II`.
17+
18+
Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not `IIII`. Instead, the number four is written as `IV`. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as `IX`. There are six instances where subtraction is used:
19+
20+
* `I` can be placed before `V` (5) and `X` (10) to make 4 and 9.
21+
* `X` can be placed before `L` (50) and `C` (100) to make 40 and 90.
22+
* `C` can be placed before `D` (500) and `M` (1000) to make 400 and 900.
23+
24+
Given a roman numeral, convert it to an integer.
25+
26+
**Example 1:**
27+
28+
**Input:** s = "III"
29+
30+
**Output:** 3
31+
32+
**Example 2:**
33+
34+
**Input:** s = "IV"
35+
36+
**Output:** 4
37+
38+
**Example 3:**
39+
40+
**Input:** s = "IX"
41+
42+
**Output:** 9
43+
44+
**Example 4:**
45+
46+
**Input:** s = "LVIII"
47+
48+
**Output:** 58
49+
50+
**Explanation:** L = 50, V= 5, III = 3.
51+
52+
**Example 5:**
53+
54+
**Input:** s = "MCMXCIV"
55+
56+
**Output:** 1994
57+
58+
**Explanation:** M = 1000, CM = 900, XC = 90 and IV = 4.
59+
60+
**Constraints:**
61+
62+
* `1 <= s.length <= 15`
63+
* `s` contains only the characters `('I', 'V', 'X', 'L', 'C', 'D', 'M')`.
64+
* It is **guaranteed** that `s` is a valid roman numeral in the range `[1, 3999]`.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /