Adv Task5 - 0144
Adv Task5 - 0144
VU21CSEN0100144
Task-5
1. https://leetcode.com/problems/unique-binary-search-trees/
Code:
class Solution {
public int numTrees(int n) {
int[] dp=new int[n+1];
Arrays.fill(dp,-1);
return helper(n,dp);
}
public int helper(int n,int[] dp){
if(n<=1) return 1;
SHREYA DHANNARAPU
VU21CSEN0100144
2. https://leetcode.com/problems/all-elements-in-two-binary-search-trees/
Code:
class Solution {
public List<Integer> getAllElements(TreeNode root1, TreeNode root2) {
Stack<TreeNode> st1 = new Stack<>();
Stack<TreeNode> st2 = new Stack<>();