242. Valid Anagram
Given, Strings s and T, write a function to determine if it is a anagram of s.
For example,
s = "Anagram", t = "Nagaram", return true.
s = "Rat", t = "Car", return false.
Note:
Assume the string contains only lowercase alphabets.
follow up:
What if the inputs contain Unicode characters? How would adapt your solution to such case?
Class solution {public: bool isanagram (string s, string t ) { if (S.size () != t.size ()) { return false; } else { int sbit[26] = {0};//record the number of occurrences of each letter int tBit[26] = {0}; const char * sp = s.c_str (); const char * tp = t.c_str (); for (Int i = 0; i < s.size () ; i + +) { sbit[* (sp+i) - ' a ']++; tbit[* (tp+i) - ' A ']++; } for (int j = 0; j < 26;j++) { if (Sbit[j] != tbit[j]) { return false; } } return true; } }};
2016-08-05 13:52:07
This article is from the "Do Your best" blog, so be sure to keep this source http://qiaopeng688.blog.51cto.com/3572484/1834716
leetCode242. Valid anagram a legal sort of word that is made up of reversed alphabetical order