Back In the print window choose "Save as PDF" as the destination
NOTE.CS

Anagram Check

1 topic · 28 Nov 2026
1

Anagram Check

Problem Solving

Definition:

Two strings are anagrams if they have the same characters (same count) but in a different order.

Example: listen / silent

Solution 1: Sorting O(n log n) · C++
string a = "listen", b = "silent";
sort(a.begin(), a.end());
sort(b.begin(), b.end());
cout << (a == b ? "Anagram" : "Not Anagram");

Note: sort() needs #include <algorithm>.