Algorithm ๐ง๐ป๐ป/Leetcode
[Leetcode,c++] Valid Anagram
dkswnkk
2021. 11. 20. 10:52
๋ฌธ์
Valid Anagram - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
์ฝ๋
class Solution {
public:
bool isAnagram(string s, string t) {
sort(s.begin(),s.end());
sort(t.begin(),t.end());
if(t==s) return true;
else return false;
}
};
ํ์ด
Anagram ์ด๋ ํ ๋ฌธ์์ด์ ๋ฌธ์๋ฅผ ๋น ์ง์์ด ์ฌ์ฉํ์ฌ ๋ค๋ฅธ ๋ฌธ์์ด์ ๋ง๋ค ์ ์๋ ๊ฒฝ์ฐ๋ฅผ ๋งํฉ๋๋ค.
๊ฐ๋จํ๊ฒ ์ ๋ ฌ์ ํด์ค ํ ๋น๊ตํด์ ํด๊ฒฐํ์ต๋๋ค.