JAVA || EASY SOLUTION || BINARY TREE || STRING ||  Beats 92.73%
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public boolean isValidSerialization(String preorder) {
        String[] pre=preorder.split(",");
        int c1=0,c2=0;
        for(int i=0;i<pre.length;i++){
            if(c2+1==c1){
                return false;
            }
            if(pre[i].equals(Character.toString('#'))){
                c1++;
            }
            else{
                c2++;
            }
        }
        return (c2+1)==c1;  
    }
}
```
['Java']