Skip to content

Commit 501a873

Browse files
updating docs
1 parent 0be2282 commit 501a873

File tree

5 files changed

+190
-4
lines changed

5 files changed

+190
-4
lines changed

Diff for: docs/.vitepress/Sidebar.js

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export default Sidebar = [
2424
text: "009 - Palindrome Number",
2525
link: "/solution/0001-0100/009 - Palindrome Number.md",
2626
},
27+
{
28+
text: "013 - Roman to Integer",
29+
link: "/solution/0001-0100/013 - Roman to Integer.md",
30+
},
2731
{
2832
text: "024 - Swap Nodes in Pairs",
2933
link: "/solution/0001-0100/024 - Swap Nodes in Pairs.md",
@@ -261,6 +265,10 @@ export default Sidebar = [
261265
text: "704 - Binary Search",
262266
link: "/solution/0701-0800/704 - Binary Search.md",
263267
},
268+
{
269+
text: "739 - Daily Temperatures",
270+
link: "/solution/0701-0800/739 - Daily Temperatures.md",
271+
},
264272
{
265273
text: "771 - Jewels and Stones",
266274
link: "/solution/0701-0800/771 - Jewels and Stones.md",

Diff for: docs/SERIALWISE.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
| **0004** | [Median of Two Sorted Arrays][4] | Array, Binary Search, Divide & Conquer | ![][hard] | |
1818
| **0007** | [Reverse Integer][7] | Math | ![][medium] | |
1919
| **0009** | [Palindrome Number][9] | Math | ![][easy] | |
20+
| **0013** | [Roman to Integer][13] | String, Math, Hash Table | ![][easy] | |
2021
| **0024** | [Swap Nodes in Pairs][24] | Linked List, Recursion | ![][medium] | |
2122
| **0026** | [Remove Duplicates][26] | Array, Two Pointers | ![][easy] | |
2223
| **0027** | [Remove Element][27] | Array, Two Pointers | ![][easy] | |
@@ -64,6 +65,7 @@
6465
| **0543** | [Diameter of Binary Tree][543] | Tree, DFS, Binary Tree | ![][easy] | |
6566
| **0653** | [Two Sum IV - Input is a BST][653] | Tree, DFS, BST, Binary Tree | ![][easy] | |
6667
| **0704** | [Binary Search][704] | Array, Binary Search | ![][easy] | |
68+
| **0739** | [Daily Temperatures][739] | Array, Stack, Monotonic Stack | ![][medium] | |
6769
| **0771** | [Jewels and Stones][771] | String, Hashtable | ![][easy] | |
6870
| **0876** | [Middle of the Linked List][876] | Linked List, Two Pointers | ![][easy] | |
6971
| **0888** | [Fair Candy Swap][888] | Array, Hash Table, Binary Search, Sorting | ![][easy] | |
@@ -86,6 +88,7 @@
8688
[4]: ./solution/0001-0100/004%20-%20Median%20of%20Two%20Sorted%20Arrays.md
8789
[7]: ./solution/0001-0100/007%20-%20Reverse%20Integer.md
8890
[9]: ./solution/0001-0100/009%20-%20Palindrome%20Number.md
91+
[13]: ./solution/0001-0100/013%20-%20Roman%20to%20Integer.md
8992
[24]: ./solution/0001-0100/024%20-%20Swap%20Nodes%20in%20Pairs.md
9093
[26]: ./solution/0001-0100/026%20-%20Remove%20Duplicates%20from%20Sorted%20Array.md
9194
[27]: ./solution/0001-0100/027%20-%20Remove%20Element.md
@@ -133,6 +136,7 @@
133136
[543]: ./solution/0501-0600/543%20-%20Diameter%20of%20Binary%20Tree.md
134137
[653]: ./solution/0601-0700/653%20-%20Two%20Sum%20IV%20-%20Input%20is%20a%20BST.md
135138
[704]: ./solution/0701-0800/704%20-%20Binary%20Search.md
139+
[739]: ./solution/0701-0800/739%20-%20Daily%20Temperatures.md
136140
[771]: ./solution/0701-0800/771%20-%20Jewels%20and%20Stones.md
137141
[876]: ./solution/0801-0900/876%20-%20Middle%20of%20the%20Linked%20List.md
138142
[888]: ./solution/0801-0900/888%20-%20Fair%20Candy%20Swap.md

Diff for: docs/TOPICWISE.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
| **0506** | [Relative Ranks][506] | Array, Sorting, Heap | ![][easy] | |
3333
| **0518** | [Coin Change 2][518] | Array, DP | ![][medium] | |
3434
| **0704** | [Binary Search][704] | Array, Binary Search | ![][easy] | |
35+
| **0739** | [Daily Temperatures][739] | Array, Stack, Monotonic Stack | ![][medium] | |
3536
| **0888** | [Fair Candy Swap][888] | Array, Hash Table, Binary Search, Sorting | ![][easy] | |
3637
| **1232** | [Check If It Is a Straight Line][1232] | Array, Math, Geometry | ![][easy] | |
3738
| **1480** | [Running Sum of 1d Array][1480] | Array, Prefix Sum | ![][easy] | |
@@ -43,6 +44,7 @@
4344

4445
| # | Solution | Tags | Difficulty | Remark |
4546
| :------: | :-----------------------------------------------------------: | :-------------------------------------------: | :---------: | :----: |
47+
| **0013** | [Roman to Integer][13] | String, Math, Hash Table | ![][easy] | |
4648
| **0058** | [Length of Last Word][58] | String | ![][easy] | |
4749
| **0072** | [Edit Distance][72] | String, DP | ![][hard] | |
4850
| **0344** | [Reverse String][344] | Two Pointers, String, Recursion | ![][easy] | |
@@ -60,6 +62,7 @@
6062
| # | Solution | Tags | Difficulty | Remark |
6163
| :------: | :---------------------------------: | :-------------------------------------------: | :---------: | :----: |
6264
| **0001** | [Two Sum][1] | Array, Hash Table | ![][easy] | |
65+
| **0013** | [Roman to Integer][13] | String, Math, Hash Table | ![][easy] | |
6366
| **0389** | [Find the Difference][389] | Hash Table, String, Bit Manipulation, Sorting | ![][easy] | |
6467
| **0442** | [Find All Duplicates][442] | Array, Hash Table | ![][medium] | |
6568
| **0653** | [Two Sum IV - Input is a BST ][653] | Tree, DFS, BST, Binary Tree | ![][easy] | |
@@ -91,6 +94,7 @@
9194
| **0002** | [Add Two Numbers][2] | Linked List, Math, Recursion | ![][medium] | |
9295
| **0007** | [Reverse Integer][7] | Math | ![][medium] | |
9396
| **0009** | [Palindrome Number][9] | Math | ![][easy] | |
97+
| **0013** | [Roman to Integer][13] | String, Math, Hash Table | ![][easy] | |
9498
| **0070** | [Climbing Stairs][70] | Math, DP, Memorization | ![][easy] | |
9599
| **0172** | [Factorial Trailiing Zeroes][172] | Math | ![][medium] | |
96100
| **0231** | [Power of Two][231] | Math, Bit Manipulation, Recursion | ![][easy] | |
@@ -251,6 +255,7 @@
251255
| **0144** | [Binary Tree Preorder Traversal][144] | Stack, Tree, DFS, Binary Tree | ![][easy] | |
252256
| **0145** | [Binary Tree Postorder Traversal][145] | Stack, Tree, DFS, Binary Tree | ![][easy] | |
253257
| **0445** | [Add Two Numbers II][445] | Linked List, Math, Stack | ![][medium] | |
258+
| **0739** | [Daily Temperatures][739] | Array, Stack, Monotonic Stack | ![][medium] | |
254259
| **1047** | [Remove All Adjacent Duplicates In String][1047] | String, Stack | ![][easy] | |
255260

256261
<!--
@@ -333,12 +338,11 @@
333338
| :-: | :------: | :--: | :--------: | :------: |
334339
-->
335340

336-
<!--
337341
## Monotonic Stack
338342

339-
| # | Solution | Tags | Difficulty | Remark |
340-
| :-: | :------: | :--: | :--------: | :------: |
341-
-->
343+
| # | Solution | Tags | Difficulty | Remark |
344+
| :------: | :-----------------------: | :---------------------------: | :---------: | :----: |
345+
| **0739** | [Daily Temperatures][739] | Array, Stack, Monotonic Stack | ![][medium] | |
342346

343347
## Recursion
344348

@@ -640,6 +644,7 @@
640644
[4]: ./solution/0001-0100/004%20-%20Median%20of%20Two%20Sorted%20Arrays.md
641645
[7]: ./solution//0001-0100/007%20-%20Reverse%20Integer.md
642646
[9]: ./solution/0001-0100/009%20-%20Palindrome%20Number.md
647+
[13]: ./solution/0001-0100/013%20-%20Roman%20to%20Integer.md
643648
[24]: ./solution/0001-0100/024%20-%20Swap%20Nodes%20in%20Pairs.md
644649
[26]: ./solution/0001-0100/026%20-%20Remove%20Duplicates%20from%20Sorted%20Array.md
645650
[27]: ./solution/0001-0100/027%20-%20Remove%20Element.md
@@ -687,6 +692,7 @@
687692
[543]: ./solution/0501-0600/543%20-%20Diameter%20of%20Binary%20Tree.md
688693
[653]: ./solution/0601-0700/653%20-%20Two%20Sum%20IV%20-%20Input%20is%20a%20BST.md
689694
[704]: ./solution/0701-0800/704%20-%20Binary%20Search.md
695+
[739]: ./solution/0701-0800/739%20-%20Daily%20Temperatures.md
690696
[771]: ./solution/0701-0800/771%20-%20Jewels%20and%20Stones.md
691697
[876]: ./solution/0801-0900/876%20-%20Middle%20of%20the%20Linked%20List.md
692698
[888]: ./solution/0801-0900/888%20-%20Fair%20Candy%20Swap.md

Diff for: docs/solution/0001-0100/013 - Roman to Integer.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# 13. Roman to Integer [![share]](https://leetcode.com/problems/roman-to-integer/)
2+
3+
![][easy]
4+
5+
## Problem Statement:
6+
7+
Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`.
8+
9+
```
10+
Symbol Value
11+
I 1
12+
V 5
13+
X 10
14+
L 50
15+
C 100
16+
D 500
17+
M 1000
18+
```
19+
20+
For example, `2` is written as `II` in Roman numeral, just two ones added together. `12` is written as `XII`, which is simply `X + II`. The number `27` is written as `XXVII`, which is `XX + V + II`.
21+
22+
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:
23+
24+
- I can be placed before `V` (5) and `X` (10) to make 4 and 9.
25+
- X can be placed before `L` (50) and `C` (100) to make 40 and 90.
26+
- C can be placed before `D` (500) and `M` (1000) to make 400 and 900.
27+
Given a roman numeral, convert it to an integer.
28+
29+
### Example 1:
30+
31+
```
32+
Input: s = "III"
33+
Output: 3
34+
Explanation: III = 3.
35+
```
36+
37+
### Example 2:
38+
39+
```
40+
Input: s = "LVIII"
41+
Output: 58
42+
Explanation: L = 50, V= 5, III = 3.
43+
```
44+
45+
### Example 3:
46+
47+
```
48+
Input: s = "MCMXCIV"
49+
Output: 1994
50+
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
51+
```
52+
53+
### Constraints:
54+
55+
```- 1 <= s.length <= 15
56+
- s contains only the characters `('I', 'V', 'X', 'L', 'C', 'D', 'M')`.
57+
- It is guaranteed that s is a valid roman numeral in the range [`1, 3999]`.
58+
```
59+
60+
## Solution:
61+
62+
::: code-group
63+
64+
```java
65+
public int romanToInt(String s) {
66+
Map<Character, Integer> map = Map.of(
67+
'I', 1,
68+
'V', 5,
69+
'X', 10,
70+
'L', 50,
71+
'C', 100,
72+
'D', 500,
73+
'M', 1000);
74+
int res = map.get(s.charAt(s.length() - 1));
75+
for (int i = s.length() - 2; i >= 0; i--) {
76+
if (map.get(s.charAt(i)) < map.get(s.charAt(i + 1)))
77+
res -= map.get(s.charAt(i));
78+
else
79+
res += map.get(s.charAt(i));
80+
}
81+
return res;
82+
}
83+
```
84+
85+
:::
86+
87+
### [_..._](#)
88+
89+
```
90+
91+
```
92+
93+
<!----------------------------------{ link }--------------------------------->
94+
95+
[share]: https://img.icons8.com/external-anggara-blue-anggara-putra/20/000000/external-share-user-interface-basic-anggara-blue-anggara-putra-2.png
96+
[easy]: https://img.shields.io/badge/Difficulty-Easy-bright.svg
97+
[medium]: https://img.shields.io/badge/Difficulty-Medium-yellow.svg
98+
[hard]: https://img.shields.io/badge/Difficulty-Hard-red.svg

Diff for: docs/solution/0701-0800/739 - Daily Temperatures.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# 739. Daily Temperatures [![share]](https://leetcode.com/problems/daily-temperatures/)
2+
3+
![][medium]
4+
5+
## Problem Statement:
6+
7+
Given an array of integers `temperatures` represents the daily temperatures, return an array `answer` such that `answer[i]` is the number of days you have to wait after the <code>i<sup>th</sup></code> day to get a warmer temperature. If there is no future day for which this is possible, keep `answer[i] == 0` instead.
8+
9+
### Example 1:
10+
11+
```
12+
Input: temperatures = [73,74,75,71,69,72,76,73]
13+
Output: [1,1,4,2,1,1,0,0]
14+
```
15+
16+
### Example 2:
17+
18+
```
19+
Input: temperatures = [30,40,50,60]
20+
Output: [1,1,1,0]
21+
```
22+
23+
### Example 3:
24+
25+
```
26+
Input: temperatures = [30,60,90]
27+
Output: [1,1,0]
28+
```
29+
30+
### Constraints:
31+
32+
- 1 <= temperatures.length <= 10<sup>5</sup>
33+
- 30 <= temperatures[i] <= 100
34+
35+
## Solution:
36+
37+
::: code-group
38+
39+
```java
40+
public int[] dailyTemperatures(int[] temp) {
41+
int n = temp.length;
42+
int[] days = new int[n];
43+
Stack<Integer> stk = new Stack<>();
44+
for (int i = n - 1; i >= 0; i--) {
45+
while (!stk.isEmpty() && temp[stk.peek()] <= temp[i])
46+
stk.pop();
47+
48+
if (!stk.isEmpty())
49+
days[i] = stk.peek() - i;
50+
51+
stk.push(i);
52+
}
53+
return days;
54+
}
55+
```
56+
57+
:::
58+
59+
### [_..._](#)
60+
61+
```
62+
63+
```
64+
65+
<!----------------------------------{ link }--------------------------------->
66+
67+
[share]: https://img.icons8.com/external-anggara-blue-anggara-putra/20/000000/external-share-user-interface-basic-anggara-blue-anggara-putra-2.png
68+
[easy]: https://img.shields.io/badge/Difficulty-Easy-bright.svg
69+
[medium]: https://img.shields.io/badge/Difficulty-Medium-yellow.svg
70+
[hard]: https://img.shields.io/badge/Difficulty-Hard-red.svg

0 commit comments

Comments
 (0)