From 64a5ef3f216f6ea75e109d47ec36b3d7e4c3de2f Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sun, 19 Nov 2023 12:38:47 +0530 Subject: [PATCH 01/20] 1st Program EASY --- README.md | 371 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 204 insertions(+), 167 deletions(-) diff --git a/README.md b/README.md index a834d0e7..4d465970 100644 --- a/README.md +++ b/README.md @@ -1,167 +1,204 @@ - - - - -## Instructions - -Git setup instructions to make contributions to the repository. - - - -## Install Git - -Download the latest version of `Git`. - -https://git-scm.com/download - - - -## Clone this repository - -Create a folder to clone the repository. - -Open the terminal and run the following git command: -```bash -git clone https://github.com/venkys-io/Code-Blogs.git -``` - - - -If this is the first time using git. A browser tab pops up to login into your GitHub account. - -and set the default config username and email. This is necessary to make any commits on the repository. - -```bash -git config --global user.name "yourUserName" -git config --global user.email "YourEmailId@gmail.com" -``` - -## Create a branch - -Change to the repository directory on your computer (if you are not already there): - -```bash -cd Code-Blogs -``` - -make sure you are in the correct directory. -```bash -C:\Users\....\Code-blogs\> -``` - -Now create a branch using `git checkout` command: - -``` -git checkout -b "yourBranchName" -``` - -you will be switched to your branch. - -## Make changes or Add your files - -Now write your blogs. - -Open vs-code in the repository. - -Shortcut: -```bash - C:\Users\....\Code-blogs\> code . -``` - - -To create a blog for the program `programs-prod/algorithms/Arrays/Easy/Palindrome` - -Create a `README.md` file as specified format. - -Example: - -
-Code-Blogs
-  └───Arrays
-        ├───Easy
-        │   └───Palindrome
-        |       └───README.md
-        └───Medium
-
-
- - -Now write the blog in `markdown`. - -To know more about markdown. visit - -[Cheatsheet1](https://www.freecodecamp.org/news/markdown-cheatsheet/)
-[Cheatsheet2](https://www.markdownguide.org/cheat-sheet/) - - - - - - - -## Commit those changes. - -Even though you have created a file. `Git` actually doesn't track those files. - -you can check the status of your branch. using `git status` command. - -```bash -git status -``` - -It displays all the changes you made on the branch. - - -Add those changes to the branch you just created using the `git add` command: - -```bash -git add . -``` - -Now commit those changes using the git commit command: - -```bash -git commit -m "your commit message" -``` - - -## Push changes to GitHub. - -push the changes using the command `git push` - -```bash -git push -u origin your-branch-name -``` - -replace your-branch-name with the name of the branch you created earlier. - - -- Note: You might get Authentication errors if it was your first time. - - - -## Raise a Pull Request for review. - -Now open GitHub to see those changes. - -Now open `pull request` tab on GitHub repository. - -Hit on Compare & Pull request. - -Mention your changes. - -Hit on create pull request. - - - - -## Suggestions - -It is good a have knowledge on Git, GitHub. - -Here are few free resources. You can try. - -[Youtube1](https://youtu.be/vwj89i2FmG0?si=C79oYDwj2A7Iqhta)
-[Youtube2](https://youtu.be/Ez8F0nW6S-w?si=FH0luDqtp9WiWqgp)
-[Youtube3](https://youtu.be/CvUiKWv2-C0?si=6Nx71vP7WXtAAbqe)
-[GitHub-Resource](https://github.com/firstcontributions/first-contributions) \ No newline at end of file +LINEAR SEARCH + +Linear search is like looking for a specific thing in a room by checking each item, one by one, until you find what you're looking for or realize it's not there. + +# Explanation Steps + + (1) Think of a room filled with items (an array with elements). + (2) You're given a specific item you want to find in the room (the target element). + (3) You start looking from one side of the room (the beginning of the array). + (4) You check each item (element) one by one. + (5) For each item, you compare it with the one you're looking for. + (6) If you find the item you're looking for, you stop searching and say you found it. + (7) If you haven't found it, you keep checking the next items. + (8) You continue until you've checked every item in the room. + (9) If you found your item, you know where it is (the index in the array). If you checked everything and didn't find it, you know it's not there. + +# Advantages of linear search + - Simplicity + - Applicability + - Ease of Implementation + - Memory Efficiency + - Optimal for Small Lists + +# Drawbacks of Linear Search: + - Linear search has a time complexity of O(N), + - which in turn makes it slow for large datasets. + - Not suitable for large arrays. + +# use Linear Search : + - When we are dealing with a small dataset. + - When you are searching for a dataset stored in contiguous memory. + - Debugging and Verification + - User Interface (UI) Elements + - data Valdation + - Sequential File Search + Online search Engines + + +# Overview of Linear Search Algorithm +Linear search is a simple searching algorithm that sequentially checks each element in a list or an +array until a match is found or the entire list has been traversed. It's also known as a sequential search. + +# Code for Linear Search in Pyhton, Java and C++ + + python + +```python +# Function to search for an element using linear search +# Takes an array and the element to find as parameters +def linear_search(array, element): + for idx, val in enumerate(array): # Using enumerate for a more Pythonic way to iterate with index + if val == element: # Print a message indicating the element is found and its index + print(f"The element {element} found at index {idx} in the given array") + # No need to continue searching if the element is found, so return from the function + return + else: # If the loop completes and the element is not found, print a message indicating so + print(f"The element {element} not found in the given array") +# Test drive code +arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +target = 10 +# Call the linear_search function to search for the target element in the array +linear_search(arr, target) +``` + +### Output +![Alt text](../Outputs/LSPY.png) + +# Explanation of the Code + - Function Definition: + The linear_search function takes in two parameters: array (the list to be searched) and element (the value being searched for). + - Iterating through the List: + It uses a for loop with enumerate to iterate through each element in the list array. + enumerate allows simultaneous access to both the index (idx) and the value (val) of each element in the list. + - Checking for a Match: + Inside the loop, it checks if the current element val matches the element being searched for. + If a match is found, it prints a message indicating the element and its index and returns from the function, ending the search. + - Completion of Loop: + If the loop completes without finding a match (i.e., the return statement is not triggered), it implies that the element is not present in the list. + In that case, it prints a message indicating that the element is not found in the given array. + - Test Drive Code: + The arr variable holds the list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], and target is set to 10, which is the element being searched for. + - Function Call: + The linear_search function is called with the array arr and the target target as arguments to search for the element in the list. + +# Time Complexity and Space Complexity + - Time Complexity: + In the worst-case scenario, the linear search algorithm has a time complexity of O(n), where n is the number of elements in the list. This is because it might need to traverse the entire list to find the element or determine that it's not present. + The average and best-case time complexities are also O(n) since the search might terminate at any position in the list. + - Space Complexity: + The space complexity of the linear search algorithm is O(1) since it doesn't require any extra space proportional to the input size. It only uses a few variables for iteration and comparison. + +# JAVA CODE + +```java +public class LinearSearch { + + // Function to search for an element using linear search + // Takes an array and the element to find as parameters + + static void linearSearch(int[] array, int element) { + for (int idx = 0; idx < array.length; idx++) { + if (array[idx] == element) { + System.out.printf("The element %d found at index %d in the given array%n", element, idx); + return; // No need to continue searching if the element is found + } + } + System.out.printf("The element %d not found in the given array%n", element); + } + + // Test drive code + public static void main(String[] args) { + int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int target = 10; + linearSearch(arr, target); + } +} +``` + +### Output +![Alt text](../Outputs/LSJAVA.png) + +# Explanation of the Code + - Function Definition: + The linearSearch method is static and void, taking two parameters: array (the array to be searched) and element (the value being searched for). + - Iterating through the Array: + It uses a for loop to iterate through each element in the array array. + The loop runs from index 0 to the length of the array (array.length - 1). + - Checking for a Match: + Inside the loop, it checks if the current element at index idx matches the element being searched for. + If a match is found, it prints a message indicating the element and its index and returns from the method, terminating the search. + - Completion of Loop: + If the loop completes without finding a match, it implies that the element is not present in the array. + In that case, it prints a message indicating that the element is not found in the given array. + - Test Drive Code: + The main method initializes an array arr with values [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], and target is set to 10, which is the element being searched for. + - Function Call: + The linearSearch method is called with the array arr and the target target as arguments to search for the element in the array. + + +# C++ Code + +''' +```c++ +#include + +// Function to search for an element using linear search +// Takes an array and the element to find as parameters + +void linearSearch(int arr[], int size, int element) { + for (int idx = 0; idx < size; idx++) { + if (arr[idx] == element) { + std::cout << "The element " << element << " found at index " << idx << " in the given array" << std::endl; + return; // No need to continue searching if the element is found + } + } + std::cout << "The element " << element << " not found in the given array" << std::endl; +} + +// Test drive code +int main() { + int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int size = sizeof(arr) / sizeof(arr[0]); // Calculate the size of the array + int target = 10; + linearSearch(arr, size, target); + return 0; +} +``` +''' + +### Output +![Alt text](../Outputs/LSC++.png) + +# Explanation of the Code + - Function Definition: + The linearSearch function takes three parameters: arr (the array to be searched), size (the size of the array), and element (the value being searched for). + - Iterating through the Array: + It uses a for loop to iterate through each element in the array arr. + The loop runs from index 0 to size - 1, where size represents the length of the array. + - Checking for a Match: + Inside the loop, it checks if the current element at index idx matches the element being searched for. + If a match is found, it prints a message indicating the element and its index and returns from the function, terminating the search. + - Completion of Loop: + If the loop completes without finding a match, it implies that the element is not present in the array. + In that case, it prints a message indicating that the element is not found in the given array. + - Test Drive Code: + The main function initializes an array arr with values [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. + The size of the array is calculated using sizeof(arr) / sizeof(arr[0]) to ensure the accurate size is passed to the function. + target is set to 10, which is the element being searched for. + - Function Call: + The linearSearch function is called with the array arr, its size size, and the target target as arguments to search for the element in the array. + + +# Real-world Applications + - Database Operations: + Linear search can be used in databases for basic search operations on unsorted datasets. + Finding Elements in Lists or Arrays: + It's applicable in scenarios where finding a specific element in a collection of data is required. + - Simple Search Operations: + Linear search can be applied in various programming scenarios where a basic search operation is needed and the dataset isn't too large. + - Handling Small Lists or Arrays: + It's efficient for small lists or arrays where the overhead of implementing complex search algorithms might not be justified. + Linear search, although straightforward, serves as a fundamental algorithmic concept and is often used as a starting point for understanding more complex searching algorithms. + + From c5b7d834d9e2549f762e8e659fbaaab47f8dcd0c Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sun, 19 Nov 2023 12:41:18 +0530 Subject: [PATCH 02/20] README.md --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 4d465970..abc6b3d9 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,7 @@ target = 10 linear_search(arr, target) ``` -### Output -![Alt text](../Outputs/LSPY.png) + # Explanation of the Code - Function Definition: @@ -116,8 +115,6 @@ public class LinearSearch { } ``` -### Output -![Alt text](../Outputs/LSJAVA.png) # Explanation of the Code - Function Definition: @@ -167,8 +164,6 @@ int main() { ``` ''' -### Output -![Alt text](../Outputs/LSC++.png) # Explanation of the Code - Function Definition: From 43ecb6c368efe028c44a4fef18ddc80be305ae14 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sun, 19 Nov 2023 12:45:03 +0530 Subject: [PATCH 03/20] Programs --- Linear Search.cpp | 22 ++++++++++++++++++++++ Linear Search.java | 23 +++++++++++++++++++++++ Linear Search.py | 16 ++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 Linear Search.cpp create mode 100644 Linear Search.java create mode 100644 Linear Search.py diff --git a/Linear Search.cpp b/Linear Search.cpp new file mode 100644 index 00000000..94a50f54 --- /dev/null +++ b/Linear Search.cpp @@ -0,0 +1,22 @@ +// C++ Code + +// Function to search for an element using linear search +// Takes an array and the element to find as parameters +void linearSearch(int arr[], int size, int element) { + for (int idx = 0; idx < size; idx++) { + if (arr[idx] == element) { + std::cout << "The element " << element << " found at index " << idx << " in the given array" << std::endl; + return; // No need to continue searching if the element is found + } + } + std::cout << "The element " << element << " not found in the given array" << std::endl; +} + +// Test drive code +int main() { + int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int size = sizeof(arr) / sizeof(arr[0]); // Calculate the size of the array + int target = 10; + linearSearch(arr, size, target); + return 0; +} diff --git a/Linear Search.java b/Linear Search.java new file mode 100644 index 00000000..1b2c40b5 --- /dev/null +++ b/Linear Search.java @@ -0,0 +1,23 @@ +// Java Code + +public class LinearSearch { + + // Function to search for an element using linear search + // Takes an array and the element to find as parameters + static void linearSearch(int[] array, int element) { + for (int idx = 0; idx < array.length; idx++) { + if (array[idx] == element) { + System.out.printf("The element %d found at index %d in the given array%n", element, idx); + return; // No need to continue searching if the element is found + } + } + System.out.printf("The element %d not found in the given array%n", element); + } + + // Test drive code + public static void main(String[] args) { + int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int target = 10; + linearSearch(arr, target); + } +} diff --git a/Linear Search.py b/Linear Search.py new file mode 100644 index 00000000..7e44b6cc --- /dev/null +++ b/Linear Search.py @@ -0,0 +1,16 @@ +# Python Code + +# Function to search for an element using linear search +# Takes an array and the element to find as parameters +def linear_search(array, element): + for idx, val in enumerate(array): # Using enumerate for a more Pythonic way to iterate with index + if val == element: + print(f"The element {element} found at index {idx} in the given array") + return # No need to continue searching if the element is found + else: + print(f"The element {element} not found in the given array") + +# Test drive code +arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +target = 10 +linear_search(arr, target) From 4c38766d806e9b6f5ba7979aa9ce799504c8b29d Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sun, 19 Nov 2023 12:51:21 +0530 Subject: [PATCH 04/20] 2ns Program ToLowerCase --- README.md (ToLowerCase).md (ToLowerCase).md | 173 ++++++++++++++++++++ ToLower Case.cpp | 36 ++++ ToLower Case.java | 31 ++++ ToLower Case.py | 22 +++ 4 files changed, 262 insertions(+) create mode 100644 README.md (ToLowerCase).md (ToLowerCase).md create mode 100644 ToLower Case.cpp create mode 100644 ToLower Case.java create mode 100644 ToLower Case.py diff --git a/README.md (ToLowerCase).md (ToLowerCase).md b/README.md (ToLowerCase).md (ToLowerCase).md new file mode 100644 index 00000000..a681344e --- /dev/null +++ b/README.md (ToLowerCase).md (ToLowerCase).md @@ -0,0 +1,173 @@ +# TO LowerCase + +# Introduction + The toLowerCase() function is a fundamental text-processing tool available in many programming languages. Its primary role is to convert all characters in a string to lowercase, ensuring uniformity and enabling case-insensitive operations within the text. This function serves as a building block in various software development tasks, offering consistency and ease of manipulation when handling textual data. + The toLowerCase() function is a method available in many programming languages that converts all characters in a string to lowercase. It's a fundamental operation when dealing with text data processing. +# Exploration: + This function provides a consistent and standardized way to convert text to lowercase, enabling uniformity and easing comparisons within strings. +# Overview of ToLowerCase +The toLowerCase() function, available in programming languages like JavaScript, Java, Python, and many others, is a method used to convert all the characters within a string to their lowercase equivalents. Its primary purpose is to ensure uniformity in textual data by standardizing the case of all letters to lowercase, facilitating case-insensitive operations. + +This function is especially useful when dealing with user inputs, comparisons, or any scenario where case differences should not affect the outcome. For instance, when validating email addresses or usernames, converting all characters to lowercase enables easier and more accurate checks without worrying about case variations. + +The toLowerCase() function does not alter the original string; instead, it returns a new string with all alphabetic characters converted to lowercase. It is a simple yet powerful tool for maintaining consistency in text processing and comparison operations. + + +# PYTHON Code + + +```python +def toLowerCase(s: str) -> str: + # Initialize an empty string to store the converted characters + lowercase = "" + + # Loop through each character in the input string + for char in s: + # Check if the character is uppercase + if 'A' <= char <= 'Z': + # Convert the uppercase character to lowercase using ASCII manipulation + lowercase += chr(ord(char) + 32) + else: + # If the character is not uppercase, keep it unchanged + lowercase += char + + # Return the converted string with lowercase characters + return lowercase + +# Test the function +string = "UpperCase" +print(toLowerCase(string)) + +``` + +### Output +![Alt text](../Screenshorts/TLCPY.png) + +# Explanation: + + - The toLowerCase() function takes a string s as input and returns the string with all characters converted to lowercase. + - It initializes an empty string lowercase to store the converted characters. + - It iterates through each character in the input string using a for loop. + - For each character, it checks if it is an uppercase letter by comparing it with ASCII values. The comparison 'A' <= char <= 'Z' ensures it's an uppercase letter. + - If the character is uppercase, it converts it to lowercase using ASCII manipulation. The ord() function gets the ASCII value of the character, adds 32 to it (the difference between uppercase and lowercase ASCII values), and then chr() converts the new ASCII value back to a character. + - If the character is not uppercase, it appends it unchanged to the lowercase string. + - Finally, it returns the lowercase string containing the original string with all characters converted to lowercase. + + +# JAVA Code + +```java +public class Main { + + // Function to convert a string to lowercase + // Returns the lowercase version of the input string + + public static String toLowerCase(String s) { + StringBuilder result = new StringBuilder(); + + // Iterate through each character in the input string + for (char c : s.toCharArray()) { + // Check if the character is an uppercase letter + if (c >= 'A' && c <= 'Z') { + // Convert uppercase to lowercase using ASCII values + result.append((char) (c + 32)); + } else { + // Keep non-uppercase characters unchanged + result.append(c); + } + } + + return result.toString(); + } + + public static void main(String[] args) { + // Example string + String inputString = "UpperCase"; + + // Convert the string to lowercase and print the result + System.out.println("Original: " + inputString); + System.out.println("Lowercase: " + toLowerCase(inputString)); + } +} +``` + +### Output +![Alt text](../Screenshorts/TLCJAVA.png) + +# Explanation: + + - The toLowerCase() method takes a string s as input and returns the string with all characters converted to lowercase. + - It initializes a StringBuilder named result to store the converted characters. + - It iterates through each character in the input string using a for-each loop (for (char c : s.toCharArray())). + - For each character, it checks if it is an uppercase letter by comparing it with ASCII values (c >= 'A' && c <= 'Z'). + - If the character is uppercase, it converts it to lowercase using ASCII values. It adds 32 to the character's ASCII value to perform this conversion (result.append((char) (c + 32));). + - If the character is not an uppercase letter, it appends it unchanged to the result StringBuilder. + - Finally, it returns the string representation of the result StringBuilder using result.toString(). + +# C++ code + +```c++ + +#include + +// Function to convert a string to lowercase +// Returns the lowercase version of the input string + +std::string toLowerCase(const std::string& s) { + // Initialize an empty string to store the lowercase result + std::string result = ""; + + // Iterate through each character in the input string + for (char i : s) { + // Check if the character is an uppercase letter + if (i >= 'A' && i <= 'Z') { + // Convert uppercase to lowercase using ASCII values and append to the result + result += static_cast(i + 32); + } else { + // Keep non-uppercase characters unchanged and append to the result + result += i; + } + } + + // Return the final lowercase result + return result; +} + +int main() { + // Example string + std::string inputString = "UpperCase"; + + // Print the original string + std::cout << "Original: " << inputString << std::endl; + + // Convert the string to lowercase using the function and print the result + std::cout << "Lowercase: " << toLowerCase(inputString) << std::endl; + + return 0; +} +``` + +### Output +![Alt text](../Screenshorts/TLCC++.png) + +# Explanation: + + - The toLowerCase function takes a constant reference to a string s as input and returns the string with all characters converted to lowercase. + - It initializes an empty string result to store the converted characters. + - It iterates through each character in the input string using a range-based for loop (for (char i : s)). + - For each character, it checks if it is an uppercase letter by comparing it with ASCII values (i >= 'A' && i <= 'Z'). + - If the character is uppercase, it converts it to lowercase using ASCII values. It adds 32 to the character's ASCII value to perform this conversion (result += static_cast(i + 32)). + - If the character is not an uppercase letter, it appends it unchanged to the result string. + - Finally, it returns the result string, which contains the input string with all characters converted to lowercase. + + +# Scheduling Problems: +While seemingly unrelated, the toLowerCase() function's uniformity can be analogous to scheduling problems. It ensures consistency, akin to scheduling entities in time slots without conflicts. + +# Real-time Applications: +The toLowerCase() function is utilized in various real-world scenarios, such as: + - Data Processing: Cleaning and standardizing textual data for analysis. + - Web Development: Sanitizing inputs for uniformity and consistency in web applications. + - Comparisons: Enabling case-insensitive comparisons in search operations or string matching algorithms. +# Summary: +The toLowerCase() function, available across multiple programming languages, is a fundamental tool for standardizing and manipulating text data. Its role spans from ensuring uniformity in text to aiding in comparisons and analysis, making it a crucial component in various software development tasks. diff --git a/ToLower Case.cpp b/ToLower Case.cpp new file mode 100644 index 00000000..d93f0450 --- /dev/null +++ b/ToLower Case.cpp @@ -0,0 +1,36 @@ +#include + +// Function to convert a string to lowercase +// Returns the lowercase version of the input string +std::string toLowerCase(const std::string& s) { + // Initialize an empty string to store the lowercase result + std::string result = ""; + + // Iterate through each character in the input string + for (char i : s) { + // Check if the character is an uppercase letter + if (i >= 'A' && i <= 'Z') { + // Convert uppercase to lowercase using ASCII values and append to the result + result += static_cast(i + 32); + } else { + // Keep non-uppercase characters unchanged and append to the result + result += i; + } + } + + // Return the final lowercase result + return result; +} + +int main() { + // Example string + std::string inputString = "UpperCase"; + + // Print the original string + std::cout << "Original: " << inputString << std::endl; + + // Convert the string to lowercase using the function and print the result + std::cout << "Lowercase: " << toLowerCase(inputString) << std::endl; + + return 0; +} \ No newline at end of file diff --git a/ToLower Case.java b/ToLower Case.java new file mode 100644 index 00000000..2507a8ff --- /dev/null +++ b/ToLower Case.java @@ -0,0 +1,31 @@ +public class Main { + + // Function to convert a string to lowercase + // Returns the lowercase version of the input string + public static String toLowerCase(String s) { + StringBuilder result = new StringBuilder(); + + // Iterate through each character in the input string + for (char c : s.toCharArray()) { + // Check if the character is an uppercase letter + if (c >= 'A' && c <= 'Z') { + // Convert uppercase to lowercase using ASCII values + result.append((char) (c + 32)); + } else { + // Keep non-uppercase characters unchanged + result.append(c); + } + } + + return result.toString(); + } + + public static void main(String[] args) { + // Example string + String inputString = "UpperCase"; + + // Convert the string to lowercase and print the result + System.out.println("Original: " + inputString); + System.out.println("Lowercase: " + toLowerCase(inputString)); + } +} \ No newline at end of file diff --git a/ToLower Case.py b/ToLower Case.py new file mode 100644 index 00000000..acf702b0 --- /dev/null +++ b/ToLower Case.py @@ -0,0 +1,22 @@ + +def multi_string_search(text, patterns): + result = [] + + for pattern in patterns: + # Use the built-in find method to check if the pattern is present in the text + if text.find(pattern) != -1: + result.append(pattern) + + return result + + +if __name__ == "__main__": + # Sample text and patterns + text = "This is a sample text for multi-string search." + patterns = ["sample", "search", "notfound"] + + # Perform multi-string search + result = multi_string_search(text, patterns) + + # Print the found patterns + print("Found patterns:", *result) From a47d533d48499196a597b7c53ea39510692b752c Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sun, 19 Nov 2023 12:53:18 +0530 Subject: [PATCH 05/20] Update Linear Search.cpp From 0fbc332b744c25dd89ce77d75929f5851edf4a16 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sun, 19 Nov 2023 12:54:01 +0530 Subject: [PATCH 06/20] Linear Search.java From 87856d7a92c91ec9ec1fe5b1c9380141cd308c22 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:37:25 +0530 Subject: [PATCH 07/20] Update and rename Linear Search.cpp to Easy/Linear Search.cpp --- Linear Search.cpp => Easy/Linear Search.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Linear Search.cpp => Easy/Linear Search.cpp (100%) diff --git a/Linear Search.cpp b/Easy/Linear Search.cpp similarity index 100% rename from Linear Search.cpp rename to Easy/Linear Search.cpp From f69cda6bdf1662d08019247dff07412f19387541 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:37:53 +0530 Subject: [PATCH 08/20] Update and rename Linear Search.java to Easy/Linear Search.java --- Linear Search.java => Easy/Linear Search.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Linear Search.java => Easy/Linear Search.java (100%) diff --git a/Linear Search.java b/Easy/Linear Search.java similarity index 100% rename from Linear Search.java rename to Easy/Linear Search.java From dc88f1079890b9eccd2150b75538cbc50f187b26 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:38:55 +0530 Subject: [PATCH 09/20] Update and rename Linear Search.py to Easy/Linear Search.py --- Linear Search.py => Easy/Linear Search.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Linear Search.py => Easy/Linear Search.py (100%) diff --git a/Linear Search.py b/Easy/Linear Search.py similarity index 100% rename from Linear Search.py rename to Easy/Linear Search.py From 858aa361f0f642a89847c73442bf6ccd43e745b9 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:40:17 +0530 Subject: [PATCH 10/20] Update and rename README.md (ToLowerCase).md (ToLowerCase).md to Easy/README.md (ToLowerCase).md (ToLowerCase).md --- .../README.md (ToLowerCase).md (ToLowerCase).md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.md (ToLowerCase).md (ToLowerCase).md => Easy/README.md (ToLowerCase).md (ToLowerCase).md (100%) diff --git a/README.md (ToLowerCase).md (ToLowerCase).md b/Easy/README.md (ToLowerCase).md (ToLowerCase).md similarity index 100% rename from README.md (ToLowerCase).md (ToLowerCase).md rename to Easy/README.md (ToLowerCase).md (ToLowerCase).md From fdf5595beb4323af6c7b5f28878681b71c96b866 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:40:31 +0530 Subject: [PATCH 11/20] Update and rename ToLower Case.cpp to Easy/ToLower Case.cpp --- ToLower Case.cpp => Easy/ToLower Case.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename ToLower Case.cpp => Easy/ToLower Case.cpp (96%) diff --git a/ToLower Case.cpp b/Easy/ToLower Case.cpp similarity index 96% rename from ToLower Case.cpp rename to Easy/ToLower Case.cpp index d93f0450..4c262353 100644 --- a/ToLower Case.cpp +++ b/Easy/ToLower Case.cpp @@ -33,4 +33,4 @@ int main() { std::cout << "Lowercase: " << toLowerCase(inputString) << std::endl; return 0; -} \ No newline at end of file +} From 9d50379be7f86253e32da808e124d08f4354f245 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:41:06 +0530 Subject: [PATCH 12/20] ToLower Case.java --- ToLower Case.java => Easy/ToLower Case.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename ToLower Case.java => Easy/ToLower Case.java (96%) diff --git a/ToLower Case.java b/Easy/ToLower Case.java similarity index 96% rename from ToLower Case.java rename to Easy/ToLower Case.java index 2507a8ff..ebbdd963 100644 --- a/ToLower Case.java +++ b/Easy/ToLower Case.java @@ -28,4 +28,4 @@ public static void main(String[] args) { System.out.println("Original: " + inputString); System.out.println("Lowercase: " + toLowerCase(inputString)); } -} \ No newline at end of file +} From 6205f80f9ebbf5b17544fdb925dc8bc1f94e8040 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:41:23 +0530 Subject: [PATCH 13/20] ToLower Case.py --- ToLower Case.py => easy/ToLower Case.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ToLower Case.py => easy/ToLower Case.py (100%) diff --git a/ToLower Case.py b/easy/ToLower Case.py similarity index 100% rename from ToLower Case.py rename to easy/ToLower Case.py From 55b3b2691c10c75d1c458f4f1a027ff5408c49a4 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:42:02 +0530 Subject: [PATCH 14/20] ToLower Case.py --- {easy => Easy}/ToLower Case.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {easy => Easy}/ToLower Case.py (100%) diff --git a/easy/ToLower Case.py b/Easy/ToLower Case.py similarity index 100% rename from easy/ToLower Case.py rename to Easy/ToLower Case.py From 7dc36b76fc0c0046f71e723cbf444ca1a7b0397a Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:42:18 +0530 Subject: [PATCH 15/20] Linear Search.cpp --- Easy/Linear Search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Easy/Linear Search.cpp b/Easy/Linear Search.cpp index 94a50f54..f0e418e8 100644 --- a/Easy/Linear Search.cpp +++ b/Easy/Linear Search.cpp @@ -1,7 +1,7 @@ // C++ Code // Function to search for an element using linear search -// Takes an array and the element to find as parameters +// Takes an array and the element to find as parameters void linearSearch(int arr[], int size, int element) { for (int idx = 0; idx < size; idx++) { if (arr[idx] == element) { From 5605d8f4a646d8bb7ea1f961e4e0bf5591da6bd1 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:42:28 +0530 Subject: [PATCH 16/20] Linear Search.java From e362112a96c1d8028bbb085fba68cfdc7113beea Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:42:39 +0530 Subject: [PATCH 17/20] Linear Search.py From 5ccc71876ebdbf3ec0f4890d4b0e114c718162f6 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:42:55 +0530 Subject: [PATCH 18/20] Update README.md From c50ffde56fee2386038c356c9143e3c8e8517e42 Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:43:09 +0530 Subject: [PATCH 19/20] ToLower Case.cpp From 7870312ebae1c29ab88b141cec114e7e2455c06f Mon Sep 17 00:00:00 2001 From: Mouni44 <137180990+Mouni44@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:43:24 +0530 Subject: [PATCH 20/20] ToLower Case.java