From 15b0ca7c15ce40dd8332ebadc4252a8d40ca633a Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 18 Nov 2021 20:18:28 +0200 Subject: [PATCH 1/5] Added description tasks 11-13. --- .../s0011_container_with_most_water/readme.md | 35 ++++++++++ .../s0012_integer_to_roman/readme.md | 48 ++++++++++++++ .../s0013_roman_to_integer/readme.md | 64 +++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 src/main/java/g0001_0100/s0011_container_with_most_water/readme.md create mode 100644 src/main/java/g0001_0100/s0012_integer_to_roman/readme.md create mode 100644 src/main/java/g0001_0100/s0013_roman_to_integer/readme.md diff --git a/src/main/java/g0001_0100/s0011_container_with_most_water/readme.md b/src/main/java/g0001_0100/s0011_container_with_most_water/readme.md new file mode 100644 index 000000000..fe94e0057 --- /dev/null +++ b/src/main/java/g0001_0100/s0011_container_with_most_water/readme.md @@ -0,0 +1,35 @@ +11\. Container With Most Water + +Medium + +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. + +**Notice** that you may not slant the container. + +**Example 1:** + +![](https://s3-lc-upload.s3.amazonaws.com/uploads/2018/07/17/question_11.jpg) + +**Input:** height = \[1,8,6,2,5,4,8,3,7\] + +**Output:** 49 + +**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. + +**Example 2:** + +**Input:** height = \[1,1\] **Output:** 1 + +**Example 3:** + +**Input:** height = \[4,3,2,1,4\] **Output:** 16 + +**Example 4:** + +**Input:** height = \[1,2,1\] **Output:** 2 + +**Constraints:** + +* `n == height.length` +* `2 <= n <= 105` +* `0 <= height[i] <= 104` \ No newline at end of file diff --git a/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md b/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md new file mode 100644 index 000000000..d3df51748 --- /dev/null +++ b/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md @@ -0,0 +1,48 @@ +12\. Integer to Roman + +Medium + +Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. + +**Symbol** **Value** + I 1 + V 5 + X 10 + L 50 + C 100 + D 500 + M 1000 + +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`. + +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: + +* `I` can be placed before `V` (5) and `X` (10) to make 4 and 9. +* `X` can be placed before `L` (50) and `C` (100) to make 40 and 90. +* `C` can be placed before `D` (500) and `M` (1000) to make 400 and 900. + +Given an integer, convert it to a roman numeral. + +**Example 1:** + +**Input:** num = 3 **Output:** "III" + +**Example 2:** + +**Input:** num = 4 **Output:** "IV" + +**Example 3:** + +**Input:** num = 9 **Output:** "IX" + +**Example 4:** + +**Input:** num = 58 **Output:** "LVIII" **Explanation:** L = 50, V = 5, III = 3. + +**Example 5:** + +**Input:** num = 1994 **Output:** "MCMXCIV" **Explanation:** M = 1000, CM = 900, XC = 90 and IV = 4. + +**Constraints:** + +* `1 <= num <= 3999` \ No newline at end of file diff --git a/src/main/java/g0001_0100/s0013_roman_to_integer/readme.md b/src/main/java/g0001_0100/s0013_roman_to_integer/readme.md new file mode 100644 index 000000000..39830255e --- /dev/null +++ b/src/main/java/g0001_0100/s0013_roman_to_integer/readme.md @@ -0,0 +1,64 @@ +13\. Roman to Integer + +Easy + +Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. + +**Symbol** **Value** + I 1 + V 5 + X 10 + L 50 + C 100 + D 500 + M 1000 + +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`. + +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: + +* `I` can be placed before `V` (5) and `X` (10) to make 4 and 9. +* `X` can be placed before `L` (50) and `C` (100) to make 40 and 90. +* `C` can be placed before `D` (500) and `M` (1000) to make 400 and 900. + +Given a roman numeral, convert it to an integer. + +**Example 1:** + +**Input:** s = "III" + +**Output:** 3 + +**Example 2:** + +**Input:** s = "IV" + +**Output:** 4 + +**Example 3:** + +**Input:** s = "IX" + +**Output:** 9 + +**Example 4:** + +**Input:** s = "LVIII" + +**Output:** 58 + +**Explanation:** L = 50, V= 5, III = 3. + +**Example 5:** + +**Input:** s = "MCMXCIV" + +**Output:** 1994 + +**Explanation:** M = 1000, CM = 900, XC = 90 and IV = 4. + +**Constraints:** + +* `1 <= s.length <= 15` +* `s` contains only the characters `('I', 'V', 'X', 'L', 'C', 'D', 'M')`. +* It is **guaranteed** that `s` is a valid roman numeral in the range `[1, 3999]`. \ No newline at end of file From 58e315737df71bc67aa0b404d336335dedf9064f Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Thu, 18 Nov 2021 20:21:49 +0200 Subject: [PATCH 2/5] Fixed description for task 12. --- .../s0012_integer_to_roman/readme.md | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md b/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md index d3df51748..065535a87 100644 --- a/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md +++ b/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md @@ -25,23 +25,37 @@ Given an integer, convert it to a roman numeral. **Example 1:** -**Input:** num = 3 **Output:** "III" +**Input:** num = 3 + +**Output:** "III" **Example 2:** -**Input:** num = 4 **Output:** "IV" +**Input:** num = 4 + +**Output:** "IV" **Example 3:** -**Input:** num = 9 **Output:** "IX" +**Input:** num = 9 + +**Output:** "IX" **Example 4:** -**Input:** num = 58 **Output:** "LVIII" **Explanation:** L = 50, V = 5, III = 3. +**Input:** num = 58 + +**Output:** "LVIII" + +**Explanation:** L = 50, V = 5, III = 3. **Example 5:** -**Input:** num = 1994 **Output:** "MCMXCIV" **Explanation:** M = 1000, CM = 900, XC = 90 and IV = 4. +**Input:** num = 1994 + +**Output:** "MCMXCIV" + +**Explanation:** M = 1000, CM = 900, XC = 90 and IV = 4. **Constraints:** From eab0114128469dbf842426cf1622aee8e191ab57 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 19 Nov 2021 01:56:26 +0200 Subject: [PATCH 3/5] Update readme.md --- .../s0011_container_with_most_water/readme.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/g0001_0100/s0011_container_with_most_water/readme.md b/src/main/java/g0001_0100/s0011_container_with_most_water/readme.md index fe94e0057..a4c45f84c 100644 --- a/src/main/java/g0001_0100/s0011_container_with_most_water/readme.md +++ b/src/main/java/g0001_0100/s0011_container_with_most_water/readme.md @@ -18,18 +18,24 @@ Given `n` non-negative integers `a1, a2, ..., an` , where each represents a poin **Example 2:** -**Input:** height = \[1,1\] **Output:** 1 +**Input:** height = \[1,1\] + +**Output:** 1 **Example 3:** -**Input:** height = \[4,3,2,1,4\] **Output:** 16 +**Input:** height = \[4,3,2,1,4\] + +**Output:** 16 **Example 4:** -**Input:** height = \[1,2,1\] **Output:** 2 +**Input:** height = \[1,2,1\] + +**Output:** 2 **Constraints:** * `n == height.length` * `2 <= n <= 105` -* `0 <= height[i] <= 104` \ No newline at end of file +* `0 <= height[i] <= 104` From be862787cea23afcb6589d0d2638f274d2f50279 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 19 Nov 2021 02:00:17 +0200 Subject: [PATCH 4/5] Update readme.md --- .../s0012_integer_to_roman/readme.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md b/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md index 065535a87..0470e12f6 100644 --- a/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md +++ b/src/main/java/g0001_0100/s0012_integer_to_roman/readme.md @@ -4,14 +4,14 @@ Medium Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. -**Symbol** **Value** - I 1 - V 5 - X 10 - L 50 - C 100 - D 500 - M 1000 + Symbol Value + I 1 + V 5 + X 10 + L 50 + C 100 + D 500 + M 1000 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`. @@ -59,4 +59,4 @@ Given an integer, convert it to a roman numeral. **Constraints:** -* `1 <= num <= 3999` \ No newline at end of file +* `1 <= num <= 3999` From 5947f8e5fceaeaf5ce8e455e316b69257dc88d0e Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Fri, 19 Nov 2021 02:02:13 +0200 Subject: [PATCH 5/5] Update readme.md --- .../s0013_roman_to_integer/readme.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/g0001_0100/s0013_roman_to_integer/readme.md b/src/main/java/g0001_0100/s0013_roman_to_integer/readme.md index 39830255e..60c47f12c 100644 --- a/src/main/java/g0001_0100/s0013_roman_to_integer/readme.md +++ b/src/main/java/g0001_0100/s0013_roman_to_integer/readme.md @@ -4,14 +4,14 @@ Easy Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. -**Symbol** **Value** - I 1 - V 5 - X 10 - L 50 - C 100 - D 500 - M 1000 + Symbol Value + I 1 + V 5 + X 10 + L 50 + C 100 + D 500 + M 1000 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`. @@ -61,4 +61,4 @@ Given a roman numeral, convert it to an integer. * `1 <= s.length <= 15` * `s` contains only the characters `('I', 'V', 'X', 'L', 'C', 'D', 'M')`. -* It is **guaranteed** that `s` is a valid roman numeral in the range `[1, 3999]`. \ No newline at end of file +* It is **guaranteed** that `s` is a valid roman numeral in the range `[1, 3999]`.