Minimum jumps to traverse all integers in range [ 1 , N ] such that integer i can jump i steps | Java implementation of the above approach ; Utility function to find minimum steps ; Driver code ; Input integer ; Function call
import java . io . * ; import java . lang . Math ; class GFG { static int minSteps ( int N ) { int res = ( ( int ) Math . sqrt ( 1 + 8 * N ) - 1 ) / 2 ; return res ; } public static void main ( String [ ] args ) { int N = 6 ; System . out . println ( minSteps ( N ) + "NEW_LINE"); } }