158.Two Strings Are Anagrams
1.Description(Easy)
Write a methodanagram(s,t)
to decide if two strings are anagrams or not.
Clarification
What is Anagram?
Two strings are anagram if they can be the same after change the order of characters.
Example
Given s ="abcd"
, t ="dcab"
, returntrue
.
Given s ="ab"
, t ="ab"
, returntrue
.
Given s ="ab"
, t ="ac"
, returnfalse
.
O(n) time, O(1) extra space
Cracking The Coding Interview String
2.Code
用HashMap解决
Last updated