标签:
Given two strings s and t, write a function to determine if t is an anagram of s.
For example,
s = "anagram", t = "nagaram", return true.
s = "rat", t = "car", return false.
Note:
You may assume the string contains only lowercase alphabets.
解法一: sort!
public class Solution { public boolean isAnagram(String s, String t) { char[] schar = s.toCharArray(); char[] tchar = t.toCharArray(); Arrays.sort(schar); Arrays.sort(tchar); s = new String(schar); t = new String(tchar); return s.equals(t); } }
标签:
原文地址:http://www.cnblogs.com/hygeia/p/4858494.html