Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. public class Solution {
  2. public int titleToNumber(String s) {
  3. int sum = 0;
  4. for(int i = s.length()-1; i >= 0; i--) {
  5. char cur = s.charAt(i);
  6. int mult = s.length() - 1 - i;
  7. sum += Math.pow(26,mult)*(cur - 'A' + 1);
  8. }
  9. return sum;
  10. }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement