25 minutes
question
Example 1:
Example
1 <= prices.length <= 105
0 <= prices[i] <= 104
your thoughts
class Solution {
public boolean isAnagram(String s, String t) {
HashMap<Character,Integer> count = new HashMap<>();
for(char ch : s.toCharArray()){
if(count.containsKey(ch)){
count.put(ch,count.get(ch)+1);
}else count.put(ch,1);
}
for(char ch : t.toCharArray()){
if(count.containsKey(ch)){
if(count.get(ch)-1 < 0) return false;
count.put(ch,count.get(ch)-1);
}else return false;
}
for(int size : count.values()){
if(size > 0) return false;
}
return true;
}
}
Very Very Bad 😔 but it passes