Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java k jump

class solution{
public static void main(String[]ar){
	Scanner in = new Scanner(System.in);
  	int k=in.nextInt();
  	int n=in.nextInt();
  	int ar[]=new int[n];
  		for(int i=0;i<n;i++){
    		ar[i]=in.nextInt();
    	}
  		int count=1,j=1,l=1,max=0,i;
  		while(l<n){
    		i=l;
          	count=1;
          	j=i;
          	while(i<n){
          		++j;
              	if(ar[j]-ar[i]>=k){
                	++count;
                  	i=j;
                }
            }
          	if(count>max){
            	max=count;
            }
          k++;
    	}
  		System.out.println(max);
	}
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to reorder numbers in a list randomly in java 
Java :: session-less control using java 
Java :: find namestart with name using strim in java 
Java :: steps to accomplish jdbc connection in java 
Java :: java array k&uuml;rzen 
Java :: vibration android studio 
Java :: delete row entity jpa java 
Java :: what is serialization and deserialization in rest assured 
Java :: Provide an ADT java class for one-dimension arrays named “MyArray” 
Java :: How can i stub Instant object using powermock 
Java :: is lower java 
Java :: String length equality 
Java :: detect view in scrollview android 
Java :: reponse entity as result spring controller 
Java :: non access modifiers in java 
Java :: Determining what type of data the ArrayList will contain in java. 
Java :: fill two dimension array java 
Java :: java.lang.ArrayIndexOutOfBoundsException: 4 
Java :: amstrong 
Java :: compare time in java 
Java :: can you override static methods in java 
Java :: java arrays method 
Java :: check if string is decimal java 
Java :: Java getClass() method 
Java :: calling a method in java 
Java :: taglib in jsp 
Java :: coin flip in java 
Java :: matlab leslie eigenvalue java 
Sql :: mysql create user with mysql_native_password 
Sql :: create database mysql utf8 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =