๋ฌธ์
์ฝ๋
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 ์ด๋ ํ ๋ฌธ์์ด์ ๋ฌธ์๋ฅผ ๋น ์ง์์ด ์ฌ์ฉํ์ฌ ๋ค๋ฅธ ๋ฌธ์์ด์ ๋ง๋ค ์ ์๋ ๊ฒฝ์ฐ๋ฅผ ๋งํฉ๋๋ค.
๊ฐ๋จํ๊ฒ ์ ๋ ฌ์ ํด์ค ํ ๋น๊ตํด์ ํด๊ฒฐํ์ต๋๋ค.
'Algorithm ๐ง๐ปโ๐ป > Leetcode' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Leetcode,c++] Happy Number (0) | 2022.03.02 |
---|---|
[Leetcode,c++] Majority Element (0) | 2021.11.28 |
[Leetcode,c++] Network Delay Time (0) | 2021.11.22 |
[Leetcode,c++] Single Number (0) | 2021.11.19 |
[Leetcode,c++] Combination Sum II (0) | 2021.11.16 |
[Leetcode,c++] Subsets II (0) | 2021.11.15 |
๋๊ธ