MCPcopy Create free account
hub / github.com/anupam-kumar-krishnan/Competitive_Programming / areAnagram

Function areAnagram

Basic Programming/anagram.cpp:3–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include <bits/stdc++.h>
2using namespace std;
3bool areAnagram(string str1, string str2)
4{
5
6 int n1 = str1.length();
7 int n2 = str2.length();
8
9 if (n1 != n2)
10 return false;
11
12 sort(str1.begin(), str1.end());
13 sort(str2.begin(), str2.end());
14
15 for (int i = 0; i < n1; i++)
16 if (str1[i] != str2[i])
17 return false;
18 return true;
19}
20
21int main()
22{

Callers 1

mainFunction · 0.85

Calls 2

sortClass · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected