Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ab64167

Browse files
committed
add No205
1 parent f5d9e79 commit ab64167

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

leetcode/String/No205.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution {
2+
public boolean isIsomorphic(String s, String t) {
3+
if(s.length() <= 1 || s == null){
4+
return true;
5+
}
6+
Map<Character,Character> hashMap = new HashMap<Character,Character>();
7+
for(int i = 0;i < s.length();i++){
8+
char a = s.charAt(i);
9+
char b = t.charAt(i);
10+
if(hashMap.containsKey(a)){
11+
if(hashMap.get(a).equals(b)){
12+
continue;
13+
}else{
14+
return false;
15+
}
16+
}else{
17+
if(!hashMap.containsValue(b)){
18+
hashMap.put(a,b);
19+
}else{
20+
return false;
21+
}
22+
}
23+
}
24+
return true;
25+
}
26+
}

0 commit comments

Comments
 (0)