leetcode242 Valid Anagram
作者:互联网
lc242 Valid Anagram
直接统计每种字母出现次数即可
1 class Solution { 2 public boolean isAnagram(String s, String t) { 3 if(s.length() != t.length()) 4 return false; 5 int[] count = new int[256]; 6 7 for(char i : s.toCharArray()){ 8 count[i]++; 9 } 10 11 for(char i : t.toCharArray()){ 12 if(--count[i] < 0) 13 return false; 14 } 15 16 return true; 17 } 18 }
标签:leetcode242,count,false,int,char,Valid,Anagram,return 来源: https://www.cnblogs.com/hwd9654/p/10958749.html