Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Easy/Isomorphic Strings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution {
public boolean isIsomorphic(String s, String t) {
HashMap<Character,Character> map1 = new HashMap<>();
HashMap<Character,Character> map2 = new HashMap<>();
for(int i=0; i<s.length(); i++){
char ch1 =s.charAt(i);
char ch2 =t.charAt(i);
if(!map1.containsKey(ch1)){
map1.put(ch1,ch2);
}
if(!map2.containsKey(ch2)){
map2.put(ch2,ch1);
}
if(map1.get(ch1)!=ch2 || map2.get(ch2)!=ch1){
return false;
}
}
return true;
}
}