Minimum jumps to traverse all integers in range [ 1 , N ] such that integer i can jump i steps | Python 3 implementation of the above approach ; Utility function to find minimum steps ; Driver code ; Input integer ; Function call
from math import sqrt NEW_LINE def minSteps ( N ) : NEW_LINE INDENT res = int ( ( sqrt ( 1 + 8 * N ) - 1 ) // 2 ) NEW_LINE return res NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 6 NEW_LINE print ( minSteps ( N ) ) NEW_LINE DEDENT