반응형
https://leetcode.com/problems/valid-anagram/description/
Valid Anagram - LeetCode
Valid Anagram - Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. E
leetcode.com
간단 정렬 문제였습니다.
📕 풀이방법
📔 풀이과정
두 문자열을 사전순으로 정렬 후 같은지 여부를 반환합니다.
📕 Code
📔 C++
class Solution {
public:
bool isAnagram(string s, string t) {
sort(s.begin(), s.end());
sort(t.begin(), t.end());
return s == t;
}
};
*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.
'Algorithm > Implementation' 카테고리의 다른 글
(C++) - LeetCode (easy) 283. Move Zeroes (0) | 2023.02.03 |
---|---|
(C++) - LeetCode (easy) 258. Add Digits (0) | 2023.01.25 |
(C++) - LeetCode (easy) 228. Summary Ranges (0) | 2023.01.12 |
(C++) - LeetCode (easy) 225. Implement Stack using Queues (0) | 2023.01.10 |
(C++) - LeetCode (easy) 219. Contains Duplicate II (0) | 2023.01.09 |