LeetCode/Top Interview Q. - Easy
LeetCode 242. Valid Anagram
벤진[Benzene]
2020. 5. 25. 09:58
Problem:
Given two strings s and t , write a function to determine if t is an anagram of s.
Example 1:
Input: s = "anagram", t = "nagaram"
Output: true
Example 2:
Input: s = "rat", t = "car"
Output: false
Note:
You may assume the string contains only lowercase alphabets.
-Summary-
1. Create two python dictionary to count each character in the string 's' and 't'.
2. If two dictionary is the same after counting each character in the string, it will return True. Otherwise, return False
정답을 보니, sorting 해서 푸는 방법도 있었다.
모든 문제에 대한 저작권은 LeetCode 회사에 있습니다. [Copyright © 2020 LeetCode]