diff --git a/coding_freshmen/JAVA/Swayam/Anagram in Java b/coding_freshmen/JAVA/Swayam/Anagram in Java new file mode 100644 index 0000000..db5ad11 --- /dev/null +++ b/coding_freshmen/JAVA/Swayam/Anagram in Java @@ -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"); +} +} diff --git a/coding_freshmen/JAVA/Swayam/Anagram.md b/coding_freshmen/JAVA/Swayam/Anagram.md new file mode 100644 index 0000000..56c814a --- /dev/null +++ b/coding_freshmen/JAVA/Swayam/Anagram.md @@ -0,0 +1,19 @@ +# +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) + +``` diff --git a/coding_freshmen/PYTHON/Sort_1.py b/coding_freshmen/PYTHON/Sort_1.py new file mode 100644 index 0000000..52dd11f --- /dev/null +++ b/coding_freshmen/PYTHON/Sort_1.py @@ -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) diff --git a/coding_freshmen/PYTHON/YTERWQ/Product_Finder.py b/coding_freshmen/PYTHON/YTERWQ/Product_Finder.py new file mode 100644 index 0000000..8bf5466 --- /dev/null +++ b/coding_freshmen/PYTHON/YTERWQ/Product_Finder.py @@ -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)) + + diff --git a/coding_freshmen/PYTHON/YTERWQ/Readme.md b/coding_freshmen/PYTHON/YTERWQ/Readme.md new file mode 100644 index 0000000..c077100 --- /dev/null +++ b/coding_freshmen/PYTHON/YTERWQ/Readme.md @@ -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) + +```