What is wrong with my code?


  • 0
    W
    public class Solution {
        public boolean isIsomorphic(String s, String t) {
            if(s.length() != t.length()){
                return false;
            }
            Map map = new HashMap();
            Map map1 = new HashMap();
            for(int i = 0; i < s.length(); i++){
                if(map.put(s.charAt(i), i) != map1.put(t.charAt(i), i)){
                    return false;
                }
            }
            return true;
        }
    }

  • 0
    L

    My code is the same as you, finanlly, i use eaquals() to compare and result has been accepted;


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.