Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anagram.c #124

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
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
32 changes: 32 additions & 0 deletions coding_freshmen/JAVA/Swayam/Anagram in Java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.io.*;
import java.util.Arrays;
import java.util.Collections;
class Main {
static boolean checkAnagram(char[] strana1, char[] strana2)
{

int len1 = strana1.length;
int len2 = strana2.length;

if (len1 != len2)
return false;

Arrays.sort(strana1);
Arrays.sort(strana2);

for (int i = 0; i < len1; i++)
if (strana1[i] != strana2[i])
return false;
return true;
}

public static void main (String args[])
{
char strana1[] = { 't', 'e', 's', 't' };
char strana2[] = { 't', 't', 'e', 'w' };
if (checkAnagram(strana1, strana2))
System.out.println("The strings to be checked are" + " anagram of each other");
else
System.out.println("The strings to be checked are not" + " anagram of each other");
}
}
19 changes: 19 additions & 0 deletions coding_freshmen/JAVA/Swayam/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)

```
11 changes: 11 additions & 0 deletions coding_freshmen/PYTHON/Sort_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import array as arr
arrr = arr.array('i',[4,2,5,9,1,8,6])
def bubblesort(arrr):
for j in range(len(arrr)-1,0,-1):
for i in range(j):
if arrr[i]> arrr[i+1]:
temp = arrr[i]
arrr[i] = arrr[i+1]
arrr[i+1] = temp
bubblesort(arrr)
print(arrr)
12 changes: 12 additions & 0 deletions coding_freshmen/PYTHON/YTERWQ/Product_Finder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def product(ar, n):

result = 1
for i in range(0, n):
result = result * ar[i]
return result
ar = [ 1, 2, 3, 4, 5 ]
n = len(ar)

print(product(ar, n))


25 changes: 25 additions & 0 deletions coding_freshmen/PYTHON/YTERWQ/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# <Title of the Problem>
Pivot_Product_Array

# Problem Explanation 🚀
you are given an array of size n.

you need to find the product of the elements of the array except the pivot element.

Input array = [0, 1, 0, 1, 0, 0, 1, 1, 1, 0]

Output array = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]

# Your logic 🤯
* Approach: Compared each element of the array with the rest of the elements and sorted accordingly
* 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)

```