Is Somorphic高频题需要bug free
严氏北美IT公司面试真题汇总和解答论坛 :: LinkedIn公司面试真题: 注册用户可以看到隐藏题目:2017年下半年上机题,8 9 10三个月的onsite面试真题 :: 数据结构的使用:HashMap
Page 1 of 1
Is Somorphic高频题需要bug free
public boolean isSomorphic(String s,String t){
if(s==null||t==null){
return false;
}
if(s.length()!=t.length()){
return false;
}
HashMap<Character,Character> map=new HashMap<Character,Character>();
for(int i=0;i<s.length();i++){
char c1=s.charAt(i);
char c2=t.charAt(i);
if(map.containsKey(c1)){
if(map.get(c1)!=c2){
return false;
}
}else{
if(map.containsValue(c2)){
return false;
}
map.put(c1, c2);
}
}
return true;
}
if(s==null||t==null){
return false;
}
if(s.length()!=t.length()){
return false;
}
HashMap<Character,Character> map=new HashMap<Character,Character>();
for(int i=0;i<s.length();i++){
char c1=s.charAt(i);
char c2=t.charAt(i);
if(map.containsKey(c1)){
if(map.get(c1)!=c2){
return false;
}
}else{
if(map.containsValue(c2)){
return false;
}
map.put(c1, c2);
}
}
return true;
}
Similar topics
» Combination SumII 不难最好bug free
» Paint House I lc原题 需bug free
» Paint HouseII lc原题需bug free 可能还会问你时间复杂度 最好用标准答案
» Combination SumIV 不难最好bug free 面试官可能让你还要用DP实现 dp在其它post中
» Length Of Longest Common Subsequence should within 3 minutes+bug free b4 onsite
» Paint House I lc原题 需bug free
» Paint HouseII lc原题需bug free 可能还会问你时间复杂度 最好用标准答案
» Combination SumIV 不难最好bug free 面试官可能让你还要用DP实现 dp在其它post中
» Length Of Longest Common Subsequence should within 3 minutes+bug free b4 onsite
严氏北美IT公司面试真题汇总和解答论坛 :: LinkedIn公司面试真题: 注册用户可以看到隐藏题目:2017年下半年上机题,8 9 10三个月的onsite面试真题 :: 数据结构的使用:HashMap
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|