Posts

Showing posts from May, 2023

Good Subtrees Problem Of The Day GFG

Problem Link: https://practice.geeksforgeeks.org/problems/df12afc57250e7f6fc101aa9c272343184fe9859/1 Solution : class Solution {     // static LinkedHashSet<Integer> set1=new LinkedHashSet<Integer>();     // static LinkedHashSet<Integer> set2=new LinkedHashSet<Integer>();         public static LinkedHashSet<Integer> fun(Node root, int k,int[] count){         if(root==null){             return new LinkedHashSet<Integer>();         }         else{             LinkedHashSet<Integer> set1=fun(root.left,k,count);             LinkedHashSet<Integer> set2=fun(root.right,k,count);             set1.addAll(set2);             set1.add(root.data);                 ...