[C++] Beginner Friendly || Simple Solution
Problem StatementThe task is to check if two strings, s and t, are anagrams. An anagram is when you can rearrange the letters of one word to make another word,
# Problem Statement
The task is to check if two strings, s and t, are anagrams. An anagram is when you can rearrange the letters of one word to make another word, using all the letters exactly once. If t is an anagram of s, return true; otherwise, return false.

**Constraints:**

- The lengths of strings s and t are between 1 and 5 * 10^4.
- Strings s and t consist of lowercase English letters.

# Solution

To check if two strings are anagrams, you can simply sort the characters in both strings and compare them. If the sorted strings are the same, then the original strings are anagrams. If not, they are not anagrams. This method returns true if the strings are anagrams and false otherwise.

**Time complexity: O(nlog n)**
**Space complexity: O(n)**
```cpp
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>

using std::cout;
using std::endl;
using std::string;

class Solution {
public:
    /**
     * @brief Checks if two strings are anagrams.
     * 
     * This function determines if two strings are anagrams by comparing their sorted versions.
     * Two strings are anagrams if they contain the same characters in the same frequency.
     * 
     * @param s The first string.
     * @param t The second string.
     * @return True if the strings are anagrams, false otherwise.
     */
    bool isAnagram(const string& s, const string& t) {
        if (s.size() != t.size())
            return false;

        std::string sorted_s = s;
        std::string sorted_t = t;
        std::sort(sorted_s.begin(), sorted_s.end());
        std::sort(sorted_t.begin(), sorted_t.end());
        return sorted_s == sorted_t;
    }
};

// Function to test the isAnagram method
void testIsAnagram() {
    Solution sol;
    // Unit test cases to validate the isAnagram method
    assert(sol.isAnagram("anagram", "nagaram") && "Test case 1 failed");
    assert(!sol.isAnagram("rat", "car") && "Test case 2 failed");
    assert(sol.isAnagram("a", "a") && "Test case 3 failed");
    assert(!sol.isAnagram("a", "ab") && "Test case 4 failed");
    assert(sol.isAnagram("listen", "silent") && "Test case 5 failed");

    cout << "All test cases passed!" << endl;
}

int main() {
    // Run the test cases
    testIsAnagram();
    return 0;
}
```
To handle both Unicode and ASCII characters properly in C++ without relying on external libraries like ICU, you can use the standard library functions with some considerations. The main challenge is to ensure that the code correctly handles Unicode characters encoded in UTF-8. This solution is efficient for checking anagram status, but may not cover other types of string comparison or manipulation that require more sophisticated Unicode handling.

For a more robust solution, especially for tasks like sorting and comparing Unicode strings according to their collation rules, you typically need to use a specialized library like ICU (International Components for Unicode).

# Frequently encountered in technical interviews
This code shows a list of companies and how many times they ask a this in an interview. 
```
std::vector<std::pair<std::string, int>> interview_frequency = {
    {"Facebook", 8}, {"Bloomberg", 8}, {"Amazon", 8},
    {"Spotify", 8},  {"Microsoft", 6}, {"Goldman Sachs", 3},
    {"Affirm", 3},   {"Google", 2},    {"Apple", 2}};
```
______________________________________________________________________
______________________________________________________________________


['Hash Table', 'String', 'Sorting', 'C++']