반응형
진짜 재수없는 문제 정답률 50.1% Medium
스터디 Tree 문제5번 백준 34단계정도
http://www.goodtecher.com/leetcode-144-binary-tree-preorder-traversal/
class Solution {
public int numTrees(int n) {
int[] ans = new int[n+1];
ans[0] = ans[1] = 1;
for(int i=2;i<=n;i++){
for(int j=1;j<=i;j++){
ans[i] += ans[j-1]*ans[i-j];
}
}
return ans[n];
}
}
반응형
'Leetcode' 카테고리의 다른 글
Leetcode <Sort> 242. Valid Anagram 백준 6996번 애너그램 (0) | 2020.04.05 |
---|---|
Leetcode 328. Odd Even Linked List 52.5% Medium (0) | 2020.04.03 |
Leetcode 621. Task Scheduler 47.7% Medium (0) | 2020.04.03 |
Leetcode <Heap> 264. Ugly Number II 38.9% Medium (0) | 2020.04.03 |
Leetcode 144. Binary Tree Preorder Traversal 54.3% Medium (0) | 2020.04.03 |
댓글