class Solution {
public String freqAlphabets(String s) {
int i = 0;
String res = "";
while(i<s.length()){
if(i+2<s.length() && s.charAt(i+2)=='#'){
String tmp = s.substring(i,i+2);
int tmp1 = Integer.parseInt(tmp);
res += (char)('a'+(tmp1-1));
i += 3;
}else{
String tmp = s.substring(i,i+1);
int tmp1 = Integer.parseInt(tmp);
res += (char)('a'+(tmp1-1));
i++;
}
}
return res;
}
}
leetcode 1309. Decrypt String from Alphabet to Integer Mapping
最新推荐文章于 2024-07-14 11:23:58 发布