Skip to content

Latest commit

 

History

History

0242.valid-anagram

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

题目

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?

解题思路

易位构词游戏的英文词汇是 anagram,这个词来源于有“反向”或“再次”的含义的希腊语字根ana-和有“书写”、“写下”的意思的词根grahpein。易位构词是一类文字游戏(更准确地说是一类“词语游戏”),是将组成一个词或短句的字母重新排列顺序,原文中所有字母的每次出现都被使用一次,这样构造出另外一些新的词或短句。

见程序注释