22. leetcode 242. Valid Anagram(由颠倒字母顺序而构成的字)

22. 242. Valid Anagram(由颠倒字母顺序而构成的字)

 

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.

Follow up:
What if the inputs contain unicode characters? How would you adapt your solution to such case?

思路:同样是利用C++ 的 map 数据结构,注意当两个字符串都为空时应该返回false。

 

posted @ 2017-04-09 21:39  蓦然闻声  阅读(192)  评论(0编辑  收藏  举报