For this Question: Given a sting S of lowercase English character's. Your task is to find the minimum length subsequence which contains all characters from 'a' to 'z' in increasing order (i. e "abcdefghijklmnopqrstuvwxyz").Input contains a single string S.

Constraints:-
1 <= |S| <= 100000

Note:- Sting will contain only lowercase english letters.Print the minimum length of such subsequence. If No such subsequence exist print -1.Sample Input:-
aaaabcdefghijklmnopqrstuvwxyabcdzzz

Sample Output:-
30

Sample Input:-
abcd

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



class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.next();
		System.out.print(checkSubstring(str));
	}

	static int checkSubstring(String str){
		int n = str.length();

		if(n < 26){
			return -1;
		}

		Deque<Integer> indexOfA = new LinkedList<>();
		for(int i=0; i<n; i++){
			if(str.charAt(i)-'a' == 0){
				if(!indexOfA.isEmpty() && indexOfA.peekLast() == i-1){
					indexOfA.removeLast();
				}
				indexOfA.addLast(i);
			}
		}
		int res = n+1;
		while(!indexOfA.isEmpty()){
			int holder = -1;
			int start = 0, end = 0;
			int i = indexOfA.removeFirst();
			for(;i<n; i++){
				if(str.charAt(i)-'a' == holder+1){
					holder++;
				}
				if(holder == 0 && str.charAt(i)-'a' == 0){
					start = i;
				}
				if(holder == 25){
					end = i;
					break;
				}
			}
			res = Math.min(res,holder==25?end-start+1:n+1);
		}

		return res==n+1?-1:res;
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?