๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm ๐Ÿง‘๐Ÿป‍๐Ÿ’ป/Leetcode

[Leetcode,c++] Valid Anagram

by dkswnkk 2021. 11. 20.

๋ฌธ์ œ

 

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

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

 

 

'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

๋Œ“๊ธ€