Skip to content

Commit d764ef7

Browse files
committed
doc: add info
1 parent b483d9c commit d764ef7

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/leet-code/0001-two-sum/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Two Sum
22

3-
Given an array of integers `nums` and an integer `target`, return the two
4-
indexes of the numbers that add up to `target`.
3+
Write a function `twoSum`, that takes an array of integers `nums` and an
4+
integer `target` as inputs, and returns the two indexes of the numbers that
5+
add up to `target`.
56

67
* Assume that `nums` contains at most one solution.
78
* Can't use the same element twice.

src/leet-code/0020-valid-parentheses/README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Valid Parentheses
22

3-
Given a string `str` consisting of the following characters: `'('`, `')'`,
4-
`'['`, `']'`, `'{'`, `'}'`, determine if `str` is valid.
3+
Write a function `hasValidParentheses`, that takes a string `str` as input, and
4+
determines whether `str` is valid.
5+
6+
The input string `str` contains just the characters: `'('`, `')'`, `'['`, `']'`,
7+
`'{'`, `'}'`.
8+
9+
Validation rules:
510

611
* Open brackets must be closed by the same type of brackets.
712
* Open brackets must be closed in the correct order.
@@ -46,3 +51,10 @@ time complexity.
4651
4752
A better approach is to iterate through the string only once, using a stack
4853
to manage the state, achieving linear time complexity.
54+
55+
## Complexity Analysis
56+
57+
| solution | time | space |
58+
| -------- | ------ | ----- |
59+
| replace | O(n^2) | O(n) |
60+
| stack | O(n) | O(n) |

0 commit comments

Comments
 (0)