Count number of steps to cover a distance if steps can be taken in powers of 2 | Function to count the minimum number of steps ; bin ( K ) . count ( "1" ) is a Python3 function to count the number of set bits in a number ; Driver Code
def getMinSteps ( K ) : NEW_LINE INDENT return bin ( K ) . count ( "1" ) NEW_LINE DEDENT n = 343 NEW_LINE print ( getMinSteps ( n ) ) NEW_LINE