Count number of steps to cover a distance if steps can be taken in powers of 2 | Java program to count minimum number of steps ; Function to count the minimum number of steps ; count the number of set bits in a number ; Driver Code
import java . io . * ; class GFG { static int getMinSteps ( int K ) { return Integer . bitCount ( K ) ; } public static void main ( String [ ] args ) { int n = 343 ; System . out . println ( getMinSteps ( n ) ) ; } }