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 ์ด๋ž€ ํ•œ ๋ฌธ์ž์—ด์˜ ๋ฌธ์ž๋ฅผ ๋น ์ง์—†์ด ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค๋ฅธ ๋ฌธ์ž์—ด์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๊ฒฝ์šฐ๋ฅผ ๋งํ•ฉ๋‹ˆ๋‹ค.

๊ฐ„๋‹จํ•˜๊ฒŒ ์ •๋ ฌ์„ ํ•ด์ค€ ํ›„ ๋น„๊ตํ•ด์„œ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.