Very easy java solution o(n^2)


#1
public class Solution {
    long factFind(int n) {
        if(n == 0) return 0;
        long res = 1;
        for(int i=1;i<=n;i++) {
            res*=i % 1000003;
            res = res % 1000003;
        }
        return res;
    }
    public int findRank(String str) {
        char[] t = str.toCharArray();
        Arrays.sort(t);
        StringBuilder temp= new StringBuilder();
        temp.append(String.valueOf(t));
        long res = 0 ;
        for(int i =0 ;i<str.length();i++){
            long fact = factFind(temp.length()-1);
            int j = temp.indexOf(String.valueOf(str.charAt(i)));
            res+= (long)j % 1000003 * fact % 1000003;
            res = res% 1000003;
            temp.deleteCharAt(j);
        }
        return ((int)res+1);
    }
}