Tough approach in java


#1

public class Solution {

public int titleToNumber(String A) {
    String arr ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int len= A.length();
    String[] str = A.split("");
    int n = str.length;
    int s=0;
    for(int i=n-1;i>=0;i--)
    {
        s = ((int)Math.pow(26,i))*(arr.indexOf(str[n-i-1])+1) + s;
    }
    return s;
}

}