File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed 
src/main/java/com/fishercoder/solutions/firstthousand Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change 88public  class  _590  {
99    public  static  class  Solution1  {
1010        public  List <Integer > postorder (Node  root ) {
11-             List <Integer > result  = new  ArrayList <>();
12-             if  (root  == null ) {
13-                 return  result ;
14-             }
15-             dfs (root , result );
16-             result .add (root .val );
17-             return  result ;
11+             return  post (root , new  ArrayList <>());
1812        }
1913
20-         private  void   dfs (Node  root , List <Integer > result ) {
14+         private  List < Integer >  post (Node  root , List <Integer > list ) {
2115            if  (root  == null ) {
22-                 return ;
16+                 return   list ;
2317            }
24-             if  (root .children .size () > 0 ) {
25-                 for  (Node  child  : root .children ) {
26-                     dfs (child , result );
27-                     result .add (child .val );
28-                 }
18+             for  (Node  child  : root .children ) {
19+                 post (child , list );
2920            }
21+             list .add (root .val );
22+             return  list ;
3023        }
3124    }
3225}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments