Beats 92%🔥|| easy JAVA Solution✅
1st Method (Simple)\n\nclass Solution {\n    public boolean isValidSerialization(String s) {\n        String arr[]=s.split(",");\n        int c=1;\n        for(
# 1st Method (Simple)\n```\nclass Solution {\n    public boolean isValidSerialization(String s) {\n        String arr[]=s.split(",");\n        int c=1;\n        for(String i:arr){\n            c--;\n            if(c<0) return false;\n            if(!i.equals("#")) c+=2;\n        }\n        return c==0;\n    }\n}\n```\n# 2nd Method (BFS)\n```\nclass Solution {\n    public boolean isValidSerialization(String s) {\n        if(s.equals("#")) return true;\n        String arr[]=s.split(",");\n        if(arr[0].equals("#")) return false;\n        Queue<String> q=new LinkedList<>();\n        q.add(arr[0]);\n        int i=0,n=arr.length;\n        while(!q.isEmpty()){\n            q.poll();\n            i++;\n            if(i==n) return false;\n            if(!arr[i].equals("#")) q.add(arr[i]);\n            i++;\n            if(i==n) return false;\n            if(!arr[i].equals("#")) q.add(arr[i]);\n        }\n        return i==n-1;\n    }\n}\n```
['Breadth-First Search', 'Java']