(String str1,String str2)
| 2 | { |
| 3 | //Function to check if two strings are isomorphic. |
| 4 | public static boolean areIsomorphic(String str1,String str2) |
| 5 | { |
| 6 | // Your code here |
| 7 | |
| 8 | if(str1.length()!=str2.length()) return false; |
| 9 | |
| 10 | HashMap<Character,Character> map = new HashMap<>(); |
| 11 | |
| 12 | for(int i=0;i<str1.length();i++) |
| 13 | { |
| 14 | char p1 = str1.charAt(i); |
| 15 | char p2 = str2.charAt(i); |
| 16 | if(map.containsKey(p1)) |
| 17 | { |
| 18 | if(map.get(p1)!=p2) return false; |
| 19 | } |
| 20 | else if(map.containsValue(p2)) |
| 21 | { |
| 22 | return false; |
| 23 | } |
| 24 | else |
| 25 | map.put(p1,p2); |
| 26 | } |
| 27 | return true; |
| 28 | } |
| 29 | } |
nothing calls this directly
no outgoing calls
no test coverage detected