题解 | #重复的DNA序列#
Excel 表列序号
http://www.nowcoder.com/practice/700738eaa67342ba8f92c13cbbb7b29d
java版:就换转换进制一样,所以要倒着遍历字符串,然后注意第一个数字是1
import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param S string字符串
* @return int整型
*/
public int getNumber (String S) {
// write code here
int result = 0;
for(int i = S.length() - 1, times = 0; i >= 0; i--, times++){
result += (int)Math.pow(26, times) * (S.charAt(i) - 'A' + 1);
}
return result;
}
}