Solution works on eclipse, but not on leetcode?


  • 0
    W

    Test case is:
    String s = "a";
    String t = "aa";

    doesn't return a...

    ''
    public char findTheDifference(String s, String t) {

    	char sChar, tChar;
    	Set<Character> sSet = new HashSet<Character>();
    	Set<Character> tSet = new HashSet<Character>();
    	
    	
    
    	for(int i = 0; i < s.length(); i++) {
    		sChar = s.charAt(i);
    		
    		sSet.add(sChar);
    
    
    	}
    	
    	for(int  j = 0; j < t.length(); j++) {
    		tChar = t.charAt(j);
    
    		tSet.add(tChar);
    		
    		if(!sSet.contains(tChar)) {
    			return tChar;
    		}
    	
    
    	}
    
    	return 't';
    
    }
    

    0_1489961114744_Screen Shot 2017-03-19 at 6.04.00 PM.png


Log in to reply
 

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