Minimum count of Full Binary Trees such that the count of leaves is N | Java implementation of the approach ; Function to return the minimum count of trees required ; To store the count of set bits in n ; Driver code
class GFG { static int minTrees ( int n ) { int count = 0 ; while ( n > 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } public static void main ( String [ ] args ) { int n = 7 ; System . out . print ( minTrees ( n ) ) ; } }