We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
import java.util.;
public class test {
public static void main(String[] args) {
/
Scanner in = new Scanner(System.in);
Deque deque = new ArrayDeque<>();
int n = in.nextInt();
int m = in.nextInt();
for (int i = 0; i < n; i++) {
int num = in.nextInt();
}*/
Scanner in=new Scanner(System.in);
List<String> li=new ArrayList<String>();
int n=in.nextInt();
int m=in.nextInt();
for(int i=0;i<n;i++)
{
li.add(in.next());
}
int sum=-1000;
for(int i=0;i<(n+1)-m;i++)
{
HashSet<String> h=new HashSet<String>();
for(int j=i;j<m+i;j++)
{
h.add(li.get(j));
}
if(sum<h.size())
{
sum=h.size();
}
h.clear();
}
System.out.println(sum);
}
}
My code is getting error in testcase 9 and timeout in testcase 8................
\ can anyone tell me the reason for the timeout or error
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Dequeue
You are viewing a single comment's thread. Return to all comments →
import java.util.; public class test { public static void main(String[] args) { / Scanner in = new Scanner(System.in); Deque deque = new ArrayDeque<>(); int n = in.nextInt(); int m = in.nextInt();
My code is getting error in testcase 9 and timeout in testcase 8................ \ can anyone tell me the reason for the timeout or error