For this Question: You have a string of lowercase characters. A character is called major character if it occurs most number of times in the string. If two or more characters have the most number of occurrence then they all are major character(s).

Print the last occurrence of the major character(s). Indexing starts from 0.First line contains a single integer N denoting the size of the string.
Second line contains the string S.

<b>constraints</b>
1 <= N <= 10<sup>5</sup>
S contains only lowercase English letters.A single integer denoting the last occurrence of the major character(s).Sample Input:
10
occurrense 

Output:
9

Explanation:
c, r and e are the major characters.
last occurrence of major character 'e' is at index 9., I have written this Solution Code: import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
       
        int n=Integer.parseInt(in.next());
        String s=in.next();

        int count[] = new int[26];
        Arrays.fill(count,0);
       
        for(int i=0;i<n;i++){
           count[s.charAt(i) - 'a']++;
        }
        
        int major=0;
        for(int i=0;i<26;i++){
            if(count[i] > major){
                major=count[i];
            }
        }
        
        int last=0;
        for(int i=0;i<n;i++){
            int j=s.charAt(i) - 'a';
            if(count[j] == major)last=i;
        }
        
        out.print(last);
        out.close();
    }

    
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }
}
, In this Programming Language: Java, Now tell me if this Code is compilable or not?