Skip to main content
1 of 2
Imus
  • 4.4k
  • 10
  • 25

Basic strategy I would use to implement strangeCount:

if(node == null || node is a leaf node) return 0. //At a leaf node we're done recursing //we know that left and right node can't both be null at this point if(left == null){ return 1 + strangeCount(right); } if (right == null) { return 1 + strangeCount(left); } //both not null return strangeCount(left) + strangeCount(right); 
Imus
  • 4.4k
  • 10
  • 25