Function to fill hd in set .
void fillSet ( Node root , HashSet < int > 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 ) { HashSet < int > set = new HashSet < int > ( ) ;