Given two strings s and t, determine if they are isomorphic.

Two strings s and t are isomorphic if the characters in s can be replaced to get t.

All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself.

&nbsp;
Example 1:
Input: s = "egg", t = "add"
Output: true
Example 2:
Input: s = "foo", t = "bar"
Output: false
Example 3:
Input: s = "paper", t = "title"
Output: true

&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 5 * 104
	t.length == s.length
	s and t consist of any valid ascii character.


class Solution:
    def isIsomorphic(self, s: str, t: str) -> bool:
        dict1={}
        m=""
		#creating a dictionary by mapping each element from string S to string T
        for i,j in zip(s,t):
		# this for the cases like "badc" and "baba" so we dont want two keys mapping to same value hence we can reject directly
            if j in dict1.values() and i not in dict1.keys():
                return False
            dict1[i]=j          
        
		#now take each letter from string s and using dictionary values replace it with that specific character
        for k in s:
            m=m+dict1[k]
			
		#now if newly formed string m == T is same then the strings are Isomorphic
        if(m==t):
            return True
        else:
            return False
class Solution {
    public boolean isIsomorphic(String s, String t) {
        
        ArrayList<Integer>list1 = new ArrayList<>();
        ArrayList<Integer>list2 = new ArrayList<>();
        for(int i=0;i<s.length();i++){
            list1.add(s.lastIndexOf(s.charAt(i)));
            list2.add(t.lastIndexOf(t.charAt(i)));
        }
        
        if(list1.equals(list2)){
            return true;
        }
        else{
            return false;
        }
    }
}
class Solution {
public:
    bool isIsomorphic(string s, string t) {
        if(s.size()!=t.size()) return false;
        unordered_map<char,char>mp;
        for(int i=0;i<s.size();i++){
            if(mp.find(s[i])==mp.end()){
                for(auto it:mp){
                    if(it.second==t[i])return false;
                }
                mp[s[i]]=t[i];
            }
            else{
                if(mp[s[i]]!=t[i]) return false;

            }

        }
        return true;

    }
};
/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
var isIsomorphic = function(s, t) {
    const obj = {};
    const setValues = new Set();
    let isIso = true;

    for(var indexI=0; indexI<s.length;indexI++) {
       if(obj[s[indexI]] || setValues.has(t[indexI])) {
            if (obj[s[indexI]] === t[indexI]) continue;

            isIso= false;
            break;
       }
       else {
           obj[s[indexI]] = t[indexI];
        setValues.add(t[indexI]);
       }
    }

    return isIso;
};
Isomorphic Strings