Function to fill hd in set .
void fillSet ( Node root , Set < Integer > set , int hd ) { if ( root == null ) return ; fillSet ( root . left , set , hd - 1 ) ; set . add ( hd ) ; fillSet ( root . right , set , hd + 1 ) ; } int verticalWidth ( Node root ) { Set < Integer > set = new HashSet < Integer > ( ) ;