Skip to content

Commit b422044

Browse files
authored
Merge pull request DaleStudy#2532 from DaleStudy/yihyun-kim1
[yihyun-kim1] WEEK 06 Solutions
2 parents 8ff6d71 + 1e89b4b commit b422044

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
const lengthOfLIS = (nums) => {
6+
const dp = new Array(nums.length).fill(1);
7+
8+
for (let i = 1; i < nums.length; i++) {
9+
for (let j = 0; j < i; j++) {
10+
if (nums[j] < nums[i]) {
11+
dp[i] = Math.max(dp[i], dp[j] + 1);
12+
}
13+
}
14+
}
15+
16+
return Math.max(...dp);
17+
};

valid-parentheses/yihyun-kim1.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
const isValid = (s) => {
6+
const stack = [];
7+
const map = { ")": "(", "}": "{", "]": "[" };
8+
9+
for (const char of s) {
10+
if (char === "(" || char === "{" || char === "[") {
11+
stack.push(char);
12+
} else {
13+
if (stack.pop() !== map[char]) return false;
14+
}
15+
}
16+
17+
return stack.length === 0;
18+
};

0 commit comments

Comments
 (0)