일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- Decorator
- 315. Count of Smaller Numbers After Self
- 컴퓨터의 구조
- LeetCode
- Class
- 파이썬
- data science
- shiba
- Python Code
- 715. Range Module
- 43. Multiply Strings
- 운영체제
- 시바견
- Python Implementation
- t1
- Protocol
- Substring with Concatenation of All Words
- 밴픽
- Convert Sorted List to Binary Search Tree
- iterator
- DWG
- attribute
- 프로그래머스
- 30. Substring with Concatenation of All Words
- 109. Convert Sorted List to Binary Search Tree
- Regular Expression
- kaggle
- Python
- Generator
- concurrency
Archives
- Today
- Total
Scribbling
[C++] LeetCode 242. Valid Anagram 본문
https://leetcode.com/problems/valid-anagram/
class Solution {
public:
bool isAnagram(string s, string t) {
if (s.size() != t.size()) {
return false;
}
unordered_map<char, int> map1;
unordered_map<char, int> map2;
for (auto c : s) {
map1[c]++;
}
for (auto c : t) {
map2[c]++;
}
for (auto x : map1) {
if (x.second != map2[x.first]) {
return false;
}
}
return true;
}
};
'Computer Science > C++' 카테고리의 다른 글
[C++] priority queue (vector<int>) with comparator (0) | 2023.08.18 |
---|---|
[C++] 49. Group Anagrams (0) | 2023.08.18 |
[C++] LeetCode 217. Contains Duplicate (0) | 2023.08.18 |
[C++ Reminder] LeetCode: 15. 3Sum (0) | 2023.01.26 |
[C++ Reminder] LeetCode 2. Add Two Numbers (0) | 2023.01.23 |