We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 81d4e12 commit 7272fdeCopy full SHA for 7272fde
valid-anagram/heozeop.cpp
@@ -0,0 +1,26 @@
1
+// Time Complexity: O(n)
2
+// Spatial Complexity: O(1)
3
+
4
+class Solution {
5
+public:
6
+ bool isAnagram(string s, string t) {
7
+ int numberOfAlphabet[26];
8
9
+ for(char character : s) {
10
+ numberOfAlphabet[character - 'a']++;
11
+ }
12
13
+ for(char character : t) {
14
+ numberOfAlphabet[character - 'a']--;
15
16
17
+ for(int i = 0; i < 26; ++i) {
18
+ if (numberOfAlphabet[i] != 0) {
19
+ return false;
20
21
22
23
+ return true;
24
25
+};
26
0 commit comments