This is my code for problem NHAY spoj.pl/problems/NHAY/
import java.util.Scanner;
class Ne{
private int dem=0;
Ne(String c1,String c2){
if (c1.length()>c2.length()) System.out.println();
else {
while (c2.indexOf(c1,dem)!=-1){
System.out.println(c2.indexOf(c1,dem));
dem=c2.indexOf(c1,dem)+1;
}
}
}
}
public class Need {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
while (sc.hasNextLine()){
String dem=sc.next();
String ch1=sc.next();
String ch2=sc.next();
Ne nn=new Ne(ch1, ch2);
}
}
}
i can't understand why I get TLE although I only use 2 loop,one for read input and one for solve.Please help me to check it..