title: Isomorphic Strings
body: <p>Given two strings s and t, determine if they are isomorphic.</p>
  
  <p>Two strings are isomorphic if the characters in s can be replaced to get t.</p>
  
  <p>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.</p>
  
  <p>For example,
  Given "egg", "add", return true.</p>
  
  <p>Given "foo", "bar", return false.</p>
  
  <p>Given "paper", "title", return true.</p>
  
  <p>Note:
  You may assume both s and t have the same length.</p>
  
  <p>I have this solution but it is taking too much time.
  Any good solution will be appreciated</p>
  
  <pre><code>   public boolean isIsomorphic(String s, String t) {
          String resString1="",resString2="";
              HashMap&lt;Character,Integer&gt; hashmapS = new HashMap(); 
              HashMap&lt;Character,Integer&gt; hashmapT = new HashMap(); 
              boolean flag = false;
              for(int i = 0;i&lt;s.length();i++)
              {
                char chS = s.charAt(i);
                char chT = t.charAt(i);
                if(hashmapS.containsKey(chS))
                {
                    resString1 = resString1 + hashmapS.get(chS);
                }
                else
                {
                    resString1 = resString1 + i; 
                    hashmapS.put(chS, i);
                }
                if(hashmapT.containsKey(chT))
                {
                    resString2 = resString2 + hashmapT.get(chT);
                }
                else
                {
                    resString2 = resString2 + i; 
                    hashmapT.put(chT, i);
                }
              }
             if(resString1.equals(resString2))
                 return true;
             else
                 return false;
      }
  </code></pre>