For this Question: Given a string S, containing only letters { 'N', 'E', 'W', 'T', 'O'} like "NWTEONEW" or "NEWTON" your task is to print all the substring of size 10 which occur more than once in the given string.Input contains a single line containing the string S.

Constraints:-
10 < = |String| < = 10000Print all the sequences in lexicographical order separated by spaces, if their is no such substring exist print -1.Sample Input:-
NEWTONNEWTONNEWTON

Sample Output:-
EWTONNEWTO NEWTONNEWT WTONNEWTON

Sample Input:-
NETOWNEWOTTONTOONW

Sample Output:-
-1, I have written this Solution Code: import java.util.*;
import java.io.*;
class Main
{

 public static List<String> repeatedString(String str){
	 HashMap<String, Integer> map = new HashMap<>();
		List <String>list = new ArrayList<>();
 	int p1= 0;
	int p2 = 10;

	while(p2 <= str.length()){
		String temp = str.substring(p1,p2);

		if(map.containsKey(temp))
		{
			if(!list.contains(temp)){
				list.add(temp);
			}
		}else{
	map.put(temp,1);
		}

		p1++; p2++;

	}
return list;

 }

    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();

		List<String> list = repeatedString(str);
		Collections.sort(list);

		if(list.size() != 0)
		for(int i = 0; i < list.size(); i++){
			System.out.print(list.get(i)+" ");
		}
		else
		System.out.print(-1);

		System.out.println();
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?