티스토리 뷰

leetcode.com/problems/valid-anagram/

 

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

파라미터로 2개의 문자열 주면 anagram이면 true 아니면 false

걍 sort시켜버리면 됨.

impl Solution {
    pub fn is_anagram(s: String, t: String) -> bool {
        let mut s_sort : Vec<char>= s.chars().collect();
        let mut t_sort : Vec<char>= t.chars().collect();
        s_sort.sort();
        t_sort.sort();
        if s_sort == t_sort{ return true;}
        false
    }
}
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함