Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions coding_freshmen/C/Sarthak/Anagram.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# <Title of the Problem>
Anagram

# Problem Explanation 🚀
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

# Your logic 🤯
* Approach: Created two arrays to hold the string and compared the array one by one
* Own test cases if any
* Code Structure and Libraries used

# Time Complexity and Space Complexity
```cpp
Example

Time Complexity -> O(n^2)
Space Complexity -> O(1)

```
35 changes: 35 additions & 0 deletions coding_freshmen/C/Sarthak/anagram.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>
#include <string.h>

int main()
{
char s[100], t[100];
printf("Enter 1st string: ");
gets(s);
printf("Enter 2nd string: ");
gets(t);
int n = 0;
int len_s = strlen(s);
int len_t = strlen(t);
for (int i = 0; i < len_s; i++)
{
for (int j = 0; j < len_t; j++)
{
if (s[i] == t[j])
{
n++;
}
}
}

if (n == len_s)
{
printf("True");
}
else
{
printf("False");
}

return 0;
}