source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
python_sharegpt_23k
843
Write a Python function to find the intersection of two lists of integers, `listA` and `listB`. The intersection should be a new list that contains only the elements that are common to both lists, and the elements in the resulting list should be in the same order as they appear in `listA`. The function should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_intersection(listA: List[int], listB: List[int]) -> List[int]: """ Finds the intersection of two lists of integers, preserving the order of elements as they appear in listA. Args: l...
python_sharegpt_23k
844
Write a Python function to return the most frequent character in a given string, considering case insensitivity. If there are multiple characters with the same frequency, return the one that appears first in the string. The input string will contain alphanumeric characters (lowercase and uppercase), spaces, and special...
Here is the Python code to solve the given problem in the markdown block: ```python def most_frequent_character(string: str) -> str: """ Returns the most frequent character in the given string, considering case insensitivity. If there are multiple characters with the same frequency, returns the one that app...
python_sharegpt_23k
846
Write a Python function to iterate through a given list and print the square root of each element if the element is a prime number between 2 and 10. If the element is not a prime number or is outside the range, print "Invalid number: {element}". If the element is greater than or equal to 10, stop iterating. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_prime(num: int) -> bool: """ Check if a number is prime. Args: num (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if...
python_sharegpt_23k
847
Write a Python function to create a copy of a list while also reversing the order of its elements, without using any built-in list methods or functions. The function should take a list as input and return a new list that is a reversed copy of the original list. The code should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_copy_list(original_list: List[int]) -> List[int]: """ Creates a copy of the given list with its elements in reverse order. Args: original_list (List[int]): The original list to b...
python_sharegpt_23k
850
Write a Python function to remove all occurrences of a target value from a given list of integers. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the list. The function should modify the list in place and return the length of the list after removing the targe...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_target_value(nums: List[int], target: int) -> int: """ Removes all occurrences of the target value from the given list of integers in place. Returns the length of the list after removing t...
python_sharegpt_23k
856
Write a Python function to determine if a given string is a palindrome, considering only alphanumeric characters and ignoring case sensitivity. The function should also ignore any spaces, special characters, and punctuation marks. The time complexity of your solution should be O(n). Additionally, the function should be...
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome(s: str) -> bool: """ Determine if a given string is a palindrome, considering only alphanumeric characters and ignoring case sensitivity. The function also ignores any spaces, special characters, and punctu...
python_sharegpt_23k
865
Write a Python function to split a string into a list of strings, separated by a given delimiter, while handling multiple nested delimiters. The function should have a time complexity of O(n), where n is the length of the input string. Additionally, the function should ignore any occurrences of the delimiter within nes...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def split_string_with_nested_delimiters(string: str, delimiter: str) -> List[str]: """ Splits a string into a list of strings, separated by a given delimiter, while handling nested delimiters. Args:...
python_sharegpt_23k
870
Write a Python function to determine if a given integer `x` is a prime number. The function should return `True` if `x` is a prime number and `False` otherwise. Implement the function without using the modulo operator (`%`) to check divisibility. Instead, use bitwise operations or other mathematical techniques to deter...
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime(x: int) -> bool: """ Determine if a given integer x is a prime number. Args: x (int): The integer to check for primality. Returns: bool: True if x is a prime number, False otherwise. ""...
python_sharegpt_23k
871
Write a Python function to determine if a given number is prime. The function should return a string "Prime" if the number is prime and "Not Prime" if it is not. The function should handle edge cases such as numbers less than 2, which are not prime by definition. The code should start with: ```python import math def ...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(num: int) -> str: """ Determine if a given number is prime and return "Prime" if it is, otherwise return "Not Prime". Args: num (int): The number to check for primality. Returns: ...
python_sharegpt_23k
873
Write a Python function to generate a list of tuples where each tuple contains the values of the outer loop variable and the inner loop variable, following the nested loop structure described. The outer loop should iterate from 1 to 10, and the inner loop should iterate from the current value of the outer loop variable...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def generate_nested_loop_tuples() -> List[Tuple[int, int]]: """ Generate a list of tuples where each tuple contains the values of the outer loop variable and the inner loop variable. The outer...
python_sharegpt_23k
878
Implement a shell sort algorithm in Python that sorts an array of integers in ascending order. The algorithm should follow these requirements: - The time complexity of your solution should be O(n^2). - You are not allowed to use any built-in sorting functions or libraries. - Your implementation should be in-place, i.e....
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def shell_sort(arr: List[int]) -> List[int]: """ Sorts an array of integers in ascending order using the Shell sort algorithm. Args: arr (List[int]): The array of integers to be sorted. ...
python_sharegpt_23k
883
Write a Python function to determine if a given number is a prime number with a time complexity of O(sqrt(n)) and space complexity of O(1). The function should efficiently check for primality by leveraging mathematical properties and optimizations. The code should start with: ```python import math def is_prime_effici...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime_efficient(n: int) -> bool: """ Determines if a given number is a prime number with O(sqrt(n)) time complexity and O(1) space complexity. Args: n (int): The number to check for primality. ...
python_sharegpt_23k
887
Write a Python function to find the index of the first occurrence of a given element in a list of integers. The function should handle cases where the element is not present in the list and return -1 in such cases. The input list should have a length of at least 5 and contain only unique elements. The function should o...
Here is the Python code to solve the given problem in the markdown block: ```python def find_first_occurrence(arr: list, element: int) -> int: """ Find the index of the first occurrence of a given element in a list of integers. Args: arr (list): A list of integers with at least 5 unique elements. ...
python_sharegpt_23k
892
Write a Python function to sort an array of numbers in descending order using only recursion. The function should not use any built-in sorting functions or methods. The code should start with: ```python from typing import List def recursive_sort_descending(arr: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def recursive_sort_descending(arr: List[int]) -> List[int]: """ Sorts an array of numbers in descending order using only recursion. Args: arr (List[int]): The array of numbers to be sorted. ...
python_sharegpt_23k
896
Write a Python function to convert a list of tuples into a dictionary. Each tuple in the list contains exactly two elements: a key and a value. The resulting dictionary should map each key to its corresponding value. If the list contains duplicate keys, the function should handle this by keeping the last occurrence of ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def convert_to_dict(array: List[Tuple[str, int]]) -> Dict[str, int]: """ Converts a list of tuples into a dictionary. Each tuple in the list contains exactly two elements: a key and a value....
python_sharegpt_23k
899
Write a Python function to find the last index of a target string in a list of strings. If the target string is not found in the list, the function should return -1. The function should iterate through the list backwards to find the last occurrence of the target string efficiently. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def last_index_of(lst: List[str], target: str) -> int: """ Find the last index of a target string in a list of strings. Args: lst (List[str]): The list of strings to search. target (...
python_sharegpt_23k
903
Write a Python function to find and output all prime numbers up to a given number `n`, while skipping any number that is divisible by 5 or 7. The function should also calculate and output the sum of all the prime numbers found, keep track of the total count of prime numbers, and check if the given number `n` is a prime...
Here is the Python code to solve the given problem in the markdown block: ```python def find_prime_numbers(n: int) -> None: """ Find and output all prime numbers up to a given number n, while skipping any number that is divisible by 5 or 7. Also, calculate and output the sum of all the prime numbers found, ...
python_sharegpt_23k
905
Write a Python function to check if a given string consists of only lowercase alphabetic characters and contains at least one vowel. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the string. The code should start with: ```python def check_lowercase_with_vow...
Here is the Python code to solve the given problem in the markdown block: ```python def check_lowercase_with_vowel(string: str) -> bool: """ Check if a given string consists of only lowercase alphabetic characters and contains at least one vowel. Args: string (str): The string to be checked. R...
python_sharegpt_23k
906
Write a Python function to filter out all prime numbers from a given list of integers using a custom primality test function. The function should not use any built-in methods or functions to determine if a number is prime. Instead, it should implement its own algorithm to check for primality. The code should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def is_prime(num: int) -> bool: """ Check if a number is prime. Args: num (int): The number to check for primality. Returns: bool: True if the number is prime, False...
python_sharegpt_23k
912
Write a Python function to capitalize the first letter of each word in a list of strings and convert all other letters to lowercase. The function should handle strings with mixed cases, special characters, digits, spaces, and strings with multiple words separated by spaces. Additionally, the function should handle stri...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def capitalize_names(names: List[str]) -> List[str]: """ Capitalizes the first letter of each word in a list of strings and converts all other letters to lowercase. Args: names (List[str]): ...
python_sharegpt_23k
925
Write a Python function to compare two binary strings and return the number of differences between them. The length of the two input strings can be up to \(10^7\) characters. The function should be implemented without using any string comparison or built-in functions for comparing characters. The function should have a...
Here is the Python code to solve the given problem in the markdown block: ```python def compare_binary_strings(str1: str, str2: str) -> int: """ Compares two binary strings and returns the number of differences between them. Args: str1 (str): The first binary string. str2 (str): The second ...
python_sharegpt_23k
926
Write a Python function to find all prime numbers within a given range `[start, end]` and return them in ascending order. Additionally, implement a helper function that checks if a given number is a prime number. The code should start with: ```python import math def is_prime(n: int) -> bool: """ Check if a giv...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(n: int) -> bool: """ Check if a given number is a prime number. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. ...
python_sharegpt_23k
927
Write a Python function to find the maximum element in a 4x4 matrix along with its row and column index. If there are multiple elements with the same maximum value, return the one with the smallest row and column index. Additionally, return a list of all indices of the maximum elements in the matrix. The function shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_max_element(matrix: List[List[int]]) -> Tuple[int, int, int, List[Tuple[int, int]]]: """ Find the maximum element in a 4x4 matrix along with its row and column index. If there are mul...
python_sharegpt_23k
931
Write a Python function to calculate the nth term of the Fibonacci sequence using constant space complexity and O(n) time complexity. The function should handle negative inputs by returning -1. The code should start with: ```python def fibonacci(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def fibonacci(n: int) -> int: """ Calculate the nth term of the Fibonacci sequence using constant space complexity and O(n) time complexity. Args: n (int): The position in the Fibonacci sequence to calculate. R...
python_sharegpt_23k
933
Write a Python function to reverse the order of elements in a given list of integers without using any built-in functions or methods for list manipulation. You can only use basic programming constructs like loops and conditional statements. The time complexity of your solution should be O(n), where n is the length of t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list(my_list: List[int]) -> List[int]: """ Reverses the order of elements in a given list of integers in place. Args: my_list (List[int]): The list of integers to be reversed. ...
python_sharegpt_23k
935
Write a Python function to calculate the product of a list of numbers, handling negative integers, float numbers, and zero values. The function should ensure that the product does not exceed a specified upper limit and return an error message if it does. Additionally, the function should check if the input list is empt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_product(numbers: List[float], upper_limit: float) -> str: """ Calculate the product of a list of numbers, ensuring the product does not exceed a specified upper limit. Args: nu...
python_sharegpt_23k
940
Write a Python function to sort a list of positive integers in-place and return a sorted list with duplicates removed. The function should have a time complexity of O(n log n) and should not use any built-in sorting functions or libraries. Additionally, the function should handle duplicate numbers in the input list and...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sort(arr: List[int], left: int, right: int) -> None: """ Sorts the given list in-place using the merge sort algorithm. Args: arr (List[int]): The list to be sorted. left (i...
python_sharegpt_23k
956
Write a Python function to reverse a list of integers in place without using any built-in functions or methods for reversing the list. The function must use only a single loop, avoid using any temporary variables or creating new lists, and maintain a time complexity of O(n), where n is the length of the list. The code...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list_in_place(nums: List[int]) -> None: """ Reverses a list of integers in place without using any built-in functions or methods. Args: nums (List[int]): The list of integers to ...
python_sharegpt_23k
960
Write a Python function to find the most frequent value in a given list of integers and non-integer values. The list may contain negative numbers and non-integer values, and it will always contain at least one repeated value. The list may be very large with millions of elements. The algorithm should have a time complex...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def find_most_frequent_value(nums: List[Union[int, float]]) -> Union[int, float]: """ Find the most frequent value in a given list of integers and non-integer values. Args: nums (List...
python_sharegpt_23k
963
Write a Python function to calculate the sum of the squares of all positive integers in a given list, ensuring that the list only contains positive integers less than or equal to 100. If the list contains any negative numbers, non-integer elements, or any number greater than 100, raise a `ValueError` with the message "...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_squares(numbers: List[int]) -> int: """ Calculate the sum of the squares of all positive integers in the given list. Args: numbers (List[int]): The list of integers to process. ...
python_sharegpt_23k
992
Write a Python function to remove all duplicates from a given list of integers while maintaining the order of the elements. The function should modify the input list in-place and return the modified list. The time complexity of the solution should be less than or equal to O(n), where n is the number of elements in the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_in_place(nums: List[int]) -> List[int]: """ Removes all duplicates from the given list of integers while maintaining the order of the elements. The function modifies the input l...
python_sharegpt_23k
993
Write a Python function to find the index of the element that occurs only once in a given array. The function must not use any built-in functions or libraries, loops, or recursion. Instead, it should use only basic data structures and algorithms provided by the programming language. The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_single_element_index(arr: List[int]) -> int: """ Find the index of the element that occurs only once in the given array. Args: arr (List[int]): The array in which to find the unique...
python_sharegpt_23k
998
Write a Python function to get all the keys from a given dictionary that have a specified value, and return them in sorted order. The dictionary will only contain string keys and integer values. The function should handle the case where the specified value is not present in the dictionary by returning an empty list. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def get_keys_with_value(dictionary: Dict[str, int], value: int) -> List[str]: """ Returns a list of keys from the given dictionary that have the specified value, sorted in alphabetical order. ...
python_sharegpt_23k
999
Write a Python function to find the pair of elements in an array that have the greatest difference, where the larger element is located at an index greater than the smaller element. The array can contain duplicates, and the solution must handle them correctly. If multiple pairs have the same maximum difference, return ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_max_difference(arr: List[int]) -> List[int]: """ Find the pair of elements in the array that have the greatest difference, where the larger element is located at an index greater than the sm...
python_sharegpt_23k
1,000
Write a Python function to determine if two given strings are anagrams of each other. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. The function should be case-insensitive and should ignore non-alphabetic characters such as spaces and punctuation marks. The function should ...
Here is the Python code to solve the given problem in the markdown block: ```python import re def are_anagrams(str1: str, str2: str) -> bool: """ Determine if two strings are anagrams of each other. Args: str1 (str): The first string to compare. str2 (str): The second string to compare. ...
python_sharegpt_23k
1,006
Write a Python function to generate the first 100 prime numbers that are also palindromes. Additionally, for each prime number found, determine its prime factors and return them in a list of tuples, where each tuple contains the prime number and its prime factors. The code should start with: ```python from typing impo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import math def is_prime(n: int) -> bool: """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise....
python_sharegpt_23k
1,008
Write a Python function to randomly shuffle a list of integers such that the smallest value is always at the beginning of the shuffled list. You are not allowed to use any built-in shuffling functions or external libraries. Implement the shuffling algorithm yourself using only logical steps. Aim to minimize the time co...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def shuffle_list_with_min_at_start(lst: List[int]) -> List[int]: """ Shuffles the list of integers such that the smallest value is always at the beginning. Args: lst (List[int]...
python_sharegpt_23k
1,009
Write a Python function to find the biggest number in a given list of integers efficiently. The function should handle the case when the list is empty and return `None` in that case. The function should also handle the case when the list contains duplicate numbers and return any one of the duplicate numbers if it is th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_biggest_number(my_list: List[int]) -> Optional[int]: """ Find the biggest number in a given list of integers efficiently. Args: my_list (List[int]): The list of integers f...
python_sharegpt_23k
1,010
Write a Python function to determine if a given number is a prime number and, if not, return its prime factors. The function should be optimized to have a time complexity of O(sqrt(n)) and should handle numbers up to 10^9. The code should start with: ```python import math def prime_check_and_factors(n: int) -> (bool, ...
Here is the Python code to solve the given problem in the markdown block: ```python import math def prime_check_and_factors(n: int) -> (bool, list): """ Determine if a given number is a prime number and, if not, return its prime factors. Args: n (int): The number to check for primality and find pr...
python_sharegpt_23k
1,021
Write a Python function to remove duplicates from a list of integers while maintaining the original order of the remaining elements. Additionally, the function should ignore any negative numbers and numbers that are divisible by 3. The function should start with: ```python from typing import List def remove_duplicates...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_and_filter(numbers: List[int]) -> List[int]: """ Removes duplicates from a list of integers while maintaining the original order. Ignores negative numbers and numbers divisible ...
python_sharegpt_23k
1,023
Write a Python function to create a dictionary that contains the names of the months as keys and the average high and low temperatures in each month as values for a specific city. The dictionary should be sorted in ascending order based on the average high temperatures. The code should start with: ```python from typing...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Tuple def sort_temperatures_by_high(city_temperatures: Dict[str, Tuple[int, int]]) -> Dict[str, Tuple[int, int]]: """ Sorts the given dictionary of monthly temperatures by the average high temperatures ...
python_sharegpt_23k
1,027
Write a Python function to remove all duplicate elements from a NumPy array and return the resulting array sorted in ascending order. The input array will only contain positive integers. The time complexity of the solution should be O(n) where n is the size of the input array. The code should start with: ```python imp...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def remove_duplicates_and_sort(arr: np.ndarray) -> np.ndarray: """ Remove all duplicate elements from a NumPy array and return the resulting array sorted in ascending order. Args: arr (np.ndarray...
python_sharegpt_23k
1,028
Write a Python function to concatenate two strings in Python with a time complexity of O(n), where n is the length of the concatenated string. The function should not use any built-in string concatenation methods such as the `+` operator or the `join()` function. Additionally, the function should handle cases where one...
Here is the Python code to solve the given problem in the markdown block: ```python def concatenate_strings(s1: str, s2: str) -> str: """ Concatenates two strings with a time complexity of O(n), where n is the length of the concatenated string. Args: s1 (str): The first string to concatenate. ...
python_sharegpt_23k
1,034
Write a Python function to convert a given integer into its hexadecimal string representation using only bitwise operations. The function should not use any built-in string conversion functions or libraries. Additionally, ensure that the solution has a time complexity of O(log n) and a space complexity of O(1), where n...
Here is the Python code to solve the given problem in the markdown block: ```python def int_to_hex_string(a_variable: int) -> str: """ Converts a given integer into its hexadecimal string representation using only bitwise operations. Args: a_variable (int): The integer to be converted. Returns...
python_sharegpt_23k
1,036
Write a Python function to create a sorted array with 10 distinct integers from 0 to 9, where each number appears only once. The array must be sorted in ascending order. The algorithm must have a time complexity of O(nlogn) and use only constant extra space. Additionally, the algorithm should not use any built-in sorti...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge(left: List[int], right: List[int]) -> List[int]: """ Merge two sorted lists into one sorted list. Args: left (List[int]): The first sorted list. right (List[int]): The seco...
python_sharegpt_23k
1,038
Write a Python function to determine if two given strings are anagrams of each other. The function should be case-insensitive and should ignore leading and trailing white spaces in the strings. Additionally, the function should consider punctuation marks and special characters while determining if the strings are anagr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple import re def are_anagrams(string1: str, string2: str) -> bool: """ Determine if two strings are anagrams of each other. The function is case-insensitive and ignores leading and trailing whitespace...
python_sharegpt_23k
1,041
Write a Python function to combine the elements of two different lists into a single list in ascending order. The elements in each list will be unique but not necessarily in ascending order. The combined list should be in ascending order, and the program should handle lists of different lengths. Implement the program w...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def combine_and_sort_lists(list_1: List[int], list_2: List[int]) -> List[int]: """ Combines the elements of two different lists into a single list in ascending order. The elements in each list are un...
python_sharegpt_23k
1,042
Write a Python function to remove duplicates from a given array and return the array in ascending order, ensuring that the resulting array contains only prime numbers. If the input array is empty or does not contain any prime numbers, return an empty array. The function should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_and_primes(arr: List[int]) -> List[int]: """ Remove duplicates from the given array and return the array in ascending order, containing only prime numbers. If the input array is...
python_sharegpt_23k
1,044
Write a Python function to determine which elements of a given list are strings and return them in reverse order. You are not allowed to use any built-in methods or functions for reversing the list directly. However, you can use any other built-in methods or functions for other operations. Additionally, you are not all...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def reverse_strings_in_list(data: List[Any]) -> List[str]: """ Extracts strings from the given list and returns them in reverse order. Args: data (List[Any]): The list containing variou...
python_sharegpt_23k
1,045
Write a Python function to generate a list of prime numbers within a specified range [start, end]. The function should return a list of all prime numbers that are greater than or equal to `start` and less than or equal to `end`. The function should use a helper function to check if a number is prime. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_prime(num: int) -> bool: """ Check if a given number is prime. Args: num (int): The number to check for primality. Returns: bool: True if the number is prime, False other...
python_sharegpt_23k
1,048
Write a Python function to apply a given CSS rule to a list of HTML elements represented as dictionaries. The CSS rule should set the text color of paragraph elements inside a specific div with the class "content" to red, but only if the paragraph element has a class of "highlight". The function should return a new lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def apply_css_rule(css_rule: str, html_elements: List[Dict]) -> List[Dict]: """ Applies a given CSS rule to a list of HTML elements represented as dictionaries. The CSS rule should set the text...
python_sharegpt_23k
1,057
Write a Python function that increments a given number by a specified amount using only bitwise operations. The function should not use any arithmetic operations, loops, or conditional statements. The time complexity of the function should be O(1). The code should start with: ```python def increment_by_bitwise(number:...
Here is the Python code to solve the given problem in the markdown block: ```python def increment_by_bitwise(number: int, amount: int) -> int: """ Increments the given number by the specified amount using only bitwise operations. Args: number (int): The base number to be incremented. amount...
python_sharegpt_23k
1,060
Write a Python function to generate a dictionary mapping each unique Keytype with a description of "What it is". The Keytype can be any string consisting of letters, numbers, and specific special characters (`_`, `-`, `.`). The function should handle the case where multiple Keytypes have the same description. Additiona...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generate_keytype_dictionary(keytypes: List[str]) -> Dict[str, List[str]]: """ Generates a dictionary mapping each unique Keytype with a description of "What it is". Args: keytypes ...
python_sharegpt_23k
1,064
Write a Python function to find the maximum element in each row of a 2-dimensional array that is divisible by 3. The function should return a list of these maximum elements for each row. If no element in a row is divisible by 3, the function should append `None` to the result list for that row. The code should start w...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_max_divisible_by_3(array: List[List[int]]) -> List[int]: """ Find the maximum element in each row of a 2-dimensional array that is divisible by 3. Args: array (List[List[int]]): A 2...
python_sharegpt_23k
1,071
Write a Python function to multiply two non-negative integers without using the multiplication operator (`*`) or any built-in multiplication functions. Additionally, you are not allowed to use any loops or recursion. The time complexity of your solution should be less than or equal to O(log n), where n is the maximum v...
Here is the Python code to solve the given problem in the markdown block: ```python def multiply_without_operator(x: int, y: int) -> int: """ Multiplies two non-negative integers without using the multiplication operator (*) or any built-in multiplication functions. The function uses bitwise operations to a...
python_sharegpt_23k
1,074
Write a Python function to calculate the size of an array of integers in bytes, assuming each integer is stored as 8 bytes. The function should have a time complexity of O(1) and should not use any built-in functions or libraries to determine the length of the array. The code should start with: ```python def get_array_...
Here is the Python code to solve the given problem in the markdown block: : ```python def get_array_size_in_bytes(array: list, length: int) -> int: """ Calculate the size of an array of integers in bytes, assuming each integer is stored as 8 bytes. Args: array (list): The array of integers. ...
python_sharegpt_23k
1,078
Write a Python function to calculate the number of trailing zeros in the factorial of a given positive integer `n`. The input value of `n` will be less than or equal to 10^6. The function should be efficient and avoid calculating the factorial directly due to potential overflow and inefficiency. The code should start ...
Here is the Python code to solve the given problem in the markdown block: ```python def count_trailing_zeros(n: int) -> int: """ Calculate the number of trailing zeros in the factorial of a given positive integer n. Args: n (int): The positive integer for which to calculate the trailing zeros in it...
python_sharegpt_23k
1,079
Write a Python function to loop through a given dictionary with the following requirements: 1. The keys of the dictionary must be sorted in descending order while looping through the dictionary. 2. The values of the dictionary must be multiplied by 2 before printing them. 3. Only the keys that are divisible by 3 should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def process_dictionary(my_dict: Dict[int, int]) -> List[Tuple[int, int]]: """ Process a dictionary by sorting its keys in descending order, filtering keys divisible by 3, multiplying the...
python_sharegpt_23k
1,080
Write a Python function to determine if a given string is a palindrome, considering only alphanumeric characters and ignoring case and special characters. The function should handle strings with multiple words and spaces. The code should start with: ```python def is_palindrome(s: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome(s: str) -> bool: """ Determines if a given string is a palindrome, considering only alphanumeric characters and ignoring case and special characters. Args: s (str): The input string to check for pa...
python_sharegpt_23k
1,081
Write a Python function that implements the quicksort algorithm to sort an array of integers in ascending order. Your function should take in an array as input and return the sorted array. Include the necessary steps involved in partitioning the array and choosing the pivot element. In your solution, make sure to hand...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def quicksort(arr: List[int]) -> List[int]: """ Sorts an array of integers in ascending order using the quicksort algorithm. Args: arr (List[int]): The array of integers to be sorted. R...
python_sharegpt_23k
1,088
Write a Python function to calculate the Employee Bonus based on the hours worked, hourly rate, and employee's performance rating. The function should validate the input parameters and raise a `ValueError` if any of the inputs are invalid. The bonus calculation should be based on the hours worked and the performance ra...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_employee_bonus(hours_worked: float, hourly_rate: float, performance_rating: float) -> int: """ Calculate the Employee Bonus based on the hours worked, hourly rate, and performance rating. Args: hours_w...
python_sharegpt_23k
1,090
Write a Python function to find the sum of all even Fibonacci numbers less than a given limit using an iterative approach. The function should not use any additional data structures to store the Fibonacci sequence. The code should start with: ```python def sum_even_fibonacci(limit: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_even_fibonacci(limit: int) -> int: """ Calculate the sum of all even Fibonacci numbers less than the given limit. Args: limit (int): The upper bound for the Fibonacci numbers to be considered. Returns: ...
python_sharegpt_23k
1,093
Write a Python function to check if a given string contains at least five consecutive special characters. Special characters are defined as any character that is not a letter or a number. The function should be case-sensitive, handle strings of any length, and return a boolean value indicating whether the string contai...
Here is the Python code to solve the given problem in the markdown block: ```python def contains_five_consecutive_special_chars(string: str) -> bool: """ Check if a given string contains at least five consecutive special characters. Special characters are defined as any character that is not a letter or a ...
python_sharegpt_23k
1,094
Write a Python function to sort an array of strings in alphabetical order using the bubble sort algorithm. The function should not use any built-in sorting functions or methods and must implement the bubble sort algorithm manually. The time complexity of the function should be O(n^2), where n is the length of the input...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort_strings(arr: List[str]) -> List[str]: """ Sorts an array of strings in alphabetical order using the bubble sort algorithm. Args: arr (List[str]): The array of strings to be s...
python_sharegpt_23k
1,097
Write a Python function to recursively process a given string and print out each unique word along with the count of its characters. The function should ignore any special characters or numbers and only consider alphabetic words. It should also handle cases where the string contains leading or trailing spaces. The func...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_unique_words(string: str, word_count: Dict[str, int] = {}) -> None: """ Recursively processes a string to count unique words and their character counts, ignoring special characters and numbers....
python_sharegpt_23k
1,104
Write a Python function to validate a given email address according to the following criteria: 1. The email address must start with a string of alphanumeric characters. 2. The string must be followed by the "@" symbol. 3. After the "@" symbol, there must be a domain name consisting of a string of alphanumeric characte...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_email(email: str) -> bool: """ Validates an email address according to the specified criteria. Args: email (str): The email address to validate. Returns: bool: True if the email ...
python_sharegpt_23k
1,111
Write a Python function to determine if a given number is prime or not. The function must be implemented from scratch without using any built-in functions or libraries specifically designed for prime number checking. The function should have a time complexity of O(log(n)), where n is the given number, and should handle...
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime(n: int) -> bool: """ Determines if a given number is prime. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. """ # Hand...
python_sharegpt_23k
1,119
Write a Python function to calculate the product of two integers using only bitwise operations, bitwise shifting, and basic arithmetic operations. The function should handle both positive and negative integers. The multiplication operator (*) and any built-in multiplication functions should not be used. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python def bitwise_multiply(x: int, y: int) -> int: """ Calculate the product of two integers using only bitwise operations, bitwise shifting, and basic arithmetic operations. Args: x (int): The first integer. y (i...
python_sharegpt_23k
1,123
Write a Python function that takes a list of positive integers as input and returns a new list containing only the numbers that are both prime and greater than 100. The function should also print the total count of numbers that meet these criteria. Additionally, implement error handling to raise an exception if the inp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def is_prime(n: int) -> bool: """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. ""...
python_sharegpt_23k
1,137
Write a Python function to sort an array of dictionaries representing tasks based on specific conditions. Each dictionary has the keys "priority", "name", and "id". The sorting conditions are as follows: 1. Tasks with a priority of 1 should be placed at the beginning of the list. 2. Tasks with a priority of 10 should b...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_tasks(tasks: List[Dict[str, int]]) -> List[Dict[str, int]]: """ Sorts an array of dictionaries representing tasks based on specific conditions. Args: tasks (List[Dict[str, int...
python_sharegpt_23k
1,140
Write a Python function to find the common elements between two lists, ensuring that the output list contains only unique elements. The function should handle cases where the input lists may contain duplicates and should be efficient, with a time complexity of O(n), where n is the total number of elements in the input ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_common_elements(list1: List[int], list2: List[int]) -> List[int]: """ Finds the common elements between two lists and returns them as a list of unique elements. Args: list1 (List[in...
python_sharegpt_23k
1,142
Write a Python function to find the maximum value and its index in a given array. The function should handle arrays with duplicate elements, negative values, and arrays with a maximum length of 10^6. The time complexity of the solution should be O(n), where n is the length of the array. Additionally, the function shoul...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Optional def find_max_value_and_index(arr: List[int]) -> Optional[Tuple[int, int]]: """ Find the maximum value and its index in a given array. Args: arr (List[int]): The array of int...
python_sharegpt_23k
1,147
Write a Python function to generate 5 unique random prime numbers between 1000 and 10000, such that the sum of the digits of each prime number is also a prime number. The function should ensure that there are no duplicate prime numbers in the final result. The code should start with: ```python from typing import List ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def is_prime(n: int) -> bool: """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. ...
python_sharegpt_23k
1,148
Write a Python function to fill a jagged 2D array with zeros using a single loop and without using any built-in functions or methods. A jagged array is an array where each inner array can have a different length. The function should modify the input array in place. The code should start with: ```python from typing imp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def fill_jagged_array_with_zeros(array: List[List[int]]) -> None: """ Fills a jagged 2D array with zeros using a single loop and without using any built-in functions or methods. Args: array ...
python_sharegpt_23k
1,149
Write a Python function to categorize each string in a given list into one of the four categories: "very short", "short", "medium", and "long". A string is considered "very short" if it has less than 2 characters, "short" if it has between 2 and 4 characters, "medium" if it has between 5 and 8 characters, and "long" if...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def categorize_strings(string_list: List[str]) -> List[str]: """ Categorizes each string in the given list into one of the four categories: "very short", "short", "medium", and "long" based on its le...
python_sharegpt_23k
1,150
Write a Python function to sort a list of user objects by their age in descending order, and then by their name in ascending order. Only users with ages between 18 and 60 (inclusive) should be included in the sorted list. If two users have the same age, their names should be compared in lexicographical order. The code...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_users(users: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Sorts a list of user objects by their age in descending order, and then by their name in ascending order. Only users wit...
python_sharegpt_23k
1,151
Write a Python function to check if one string (`s2`) is a substring of another string (`s1`). The function should return `True` if `s2` is a substring of `s1`, and `False` otherwise. The function should have a time complexity of O(n), where n is the length of `s1`. The code should start with: ```python def is_substri...
Here is the Python code to solve the given problem in the markdown block: ```python def is_substring(s1: str, s2: str) -> bool: """ Check if s2 is a substring of s1. Args: s1 (str): The main string in which to search for the substring. s2 (str): The substring to search for in s1. Retur...
python_sharegpt_23k
1,152
Write a Python function to combine all the subarrays from a given list of arrays into a single array, ordered by the lengths of the subarrays. If two subarrays have the same length, their order should be preserved as they appear in the input list. The code should start with: ```python from typing import List def comb...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def combine_subarrays_by_length(arrays: List[List[int]]) -> List[int]: """ Combines all the subarrays from a given list of arrays into a single array, ordered by the lengths of the subarrays. Args: ...
python_sharegpt_23k
1,154
Write a Python function to sort an unsorted array of integers using the quick sort algorithm. The array will contain both positive and negative numbers. The output should be in ascending order. If there are duplicate numbers, they should be placed next to each other in the sorted array. Implement the quick sort algorit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def quick_sort(arr: List[int]) -> List[int]: """ Sorts an unsorted array of integers using the quick sort algorithm. Args: arr (List[int]): The unsorted array of integers. Returns: ...
python_sharegpt_23k
1,165
Write a Python function to determine if a given number is a prime number. The function should return `True` if the number is prime and `False` otherwise. Additionally, write a function to print all prime numbers within a specified range, along with a message indicating whether each number is prime or not. The code sho...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(n: int) -> bool: """ Determine if a given number is a prime number. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwis...
python_sharegpt_23k
1,167
Write a Python function to repeat a given string a specified number of times. The function should handle special characters, unicode characters, and emojis. It should also handle negative integers by reversing the string before repeating. The function should raise an exception if the string is empty or if the integer i...
Here is the Python code to solve the given problem in the markdown block: ```python def repeat_string(string: str, num: int) -> str: """ Repeats a given string a specified number of times. If the integer is negative, the string is reversed before repeating. Args: string (str): The string to be repe...
python_sharegpt_23k
1,175
Write a Python function to count the occurrences of each unique string in a given list of strings, considering case insensitivity. The function should also count the occurrences of words from an input string, treating each word separated by whitespace as a separate string. The function should return a dictionary where ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_string_occurrences(input_string: str, string_list: List[str]) -> Dict[str, int]: """ Counts the occurrences of each unique string in the given list of strings and the input string, consid...
python_sharegpt_23k
1,181
Write a Python function to find the key corresponding to the maximum value in a given dictionary. The function should not use the built-in `max()` function or any sorting functions, and it should iterate over the dictionary only once. The code should start with: ```python from typing import Dict, Any def find_max_key...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def find_max_key(dictionary: Dict[Any, int]) -> Any: """ Find the key corresponding to the maximum value in a given dictionary. Args: dictionary (Dict[Any, int]): The dictionary from wh...
python_sharegpt_23k
1,185
Write a Python function to find the largest and smallest numbers in a given list of integers. The function should meet the following requirements: 1. The function should run in O(n) time complexity, where n is the size of the input list. 2. The function should not use any built-in functions or libraries to find the lar...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_largest_smallest(numbers: List[int]) -> Tuple[int, int]: """ Find the largest and smallest numbers in a given list of integers. Args: numbers (List[int]): The list of integer...
python_sharegpt_23k
1,197
Write a Python function to calculate the sum of the first `n` Fibonacci numbers. The function should take an integer `n` as input and return the sum of the first `n` Fibonacci numbers. The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the previous two numbers. The code should start w...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_first_n_fibonacci(n: int) -> int: """ Calculate the sum of the first n Fibonacci numbers. Args: n (int): The number of Fibonacci numbers to sum. Returns: int: The sum of the first n Fibonacci...
python_sharegpt_23k
1,199
Write a Python function to calculate the binomial coefficient for two non-negative integers, `n` and `r`, where `n` is greater than or equal to `r`. The function should return the binomial coefficient as an integer. The binomial coefficient, denoted as `C(n, r)`, represents the number of ways to choose `r` items from a...
Here is the Python code to solve the given problem in the markdown block: ```python def binomial_coefficient(n: int, r: int) -> int: """ Calculate the binomial coefficient C(n, r) for two non-negative integers n and r, where n is greater than or equal to r. The binomial coefficient C(n, r) represents t...
python_sharegpt_23k
1,206
Write a Python function to calculate the product of all non-negative elements in a given list of integers. The function should skip any negative numbers and continue with the calculation. The code should start with: ```python from typing import List def product_of_non_negatives(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def product_of_non_negatives(numbers: List[int]) -> int: """ Calculate the product of all non-negative elements in a given list of integers. Args: numbers (List[int]): A list of integers. ...
python_sharegpt_23k
1,207
Write a Python function to sort an array in ascending order using a divide and conquer algorithm such as merge sort or quicksort. The function should not use any built-in sorting functions or methods, and the time complexity must be O(n log n). The array can contain both positive and negative integers, and the function...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge(left: List[int], right: List[int]) -> List[int]: """ Merge two sorted lists into a single sorted list. Args: left (List[int]): The first sorted list. right (List[int]): The...
python_sharegpt_23k
1,213
Write a Python function to find all indices of a target element in a sorted array that can contain duplicates. The function should have a time complexity of O(log n) in the worst case scenario. If the target element is not found, the function should return an empty list. The array size can be up to 10^6. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_all_indices(arr: List[int], target: int) -> List[int]: """ Find all indices of a target element in a sorted array with duplicates. Args: arr (List[int]): The sorted array to search....
python_sharegpt_23k
1,220
Write a Python function to sort an array in descending order using only a single for loop. The function should modify the input array in place and return the sorted array. The code should start with: ```python from typing import List def sort_array_descending(arr: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_array_descending(arr: List[int]) -> List[int]: """ Sorts the input array in descending order using a single for loop. Args: arr (List[int]): The array to be sorted. Returns: ...
python_sharegpt_23k
1,222
Write a Python function to convert each character in a given string to its corresponding ASCII value. The function should return a list of integers representing the ASCII values of the characters in the input string. The function must handle all characters, including Unicode characters, without using any built-in funct...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_to_ascii(string: str) -> list[int]: """ Converts each character in the input string to its corresponding ASCII value. Args: string (str): The input string to be converted. Returns: list[int]...
python_sharegpt_23k
1,226
Write a Python function to check if a given list of integers is sorted in ascending order. The function should return `True` if the list is sorted in ascending order, and `False` otherwise. The time complexity of the function should be O(n log n), where n is the length of the list. Additionally, the function should use...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_sorted_ascending(arr: List[int]) -> bool: """ Check if a given list of integers is sorted in ascending order. Args: arr (List[int]): The list of integers to check. Returns: ...
python_sharegpt_23k
1,227
Write a Python function to generate an array of fifteen unique random numbers between 1 and 1000, where each number must be divisible by 4, not divisible by 7, and not a perfect square. Additionally, the array should be sorted in descending order. The code should start with: ```python from typing import List import ra...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_special_array() -> List[int]: """ Generates an array of fifteen unique random numbers between 1 and 1000, where each number: - Is divisible by 4. - Is not divisible by ...
python_sharegpt_23k
1,235
Write a Python function to find the index of the first occurrence of an element in a given sorted list of unique integers, but only consider elements that are greater than 5 and less than 10. If no such element is found, return -1. The code should start with: ```python from typing import List def find_first_occurrenc...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_first_occurrence(lst: List[int], element: int) -> int: """ Find the index of the first occurrence of an element in a sorted list of unique integers, but only consider elements that are great...
python_sharegpt_23k
1,244
Write a Python function to generate a sorted array of size `n` filled with unique random numbers between `1` and `m`, where `n` is less than or equal to `m`. The array must be sorted in descending order. The code should start with: ```python from typing import List import random def generate_sorted_unique_random_numb...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_sorted_unique_random_numbers(n: int, m: int) -> List[int]: """ Generates a sorted array of size `n` filled with unique random numbers between `1` and `m` in descending order. ...
python_sharegpt_23k
1,246
Write a Python function that takes a string as input and converts it to a list of characters. The function should return the list. Additionally, the function should handle cases where the input string may contain non-alphabetic characters and remove any punctuation marks or special characters from the resulting list. T...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import string def convert_string_to_list(string_input: str) -> List[str]: """ Converts a string to a list of characters, removing non-alphabetic characters and collapsing multiple consecutive spaces. ...
python_sharegpt_23k
1,257
Write a Python function to sort its arguments in descending order, but only for numbers greater than or equal to 5. The function should also remove any duplicates from the sorted list. The input list may contain both numbers and strings. If a string is encountered, it should be ignored during the sorting process. The o...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def sort_numbers(nums: List[Union[int, str, List]]) -> List[int]: """ Sorts the numbers in the input list that are greater than or equal to 5 in descending order, while ignoring strings and ha...
python_sharegpt_23k
1,258
Write a Python function to return the character at a given index in a string, ensuring that the function adheres to the constraints provided. The function should handle Unicode characters and support multibyte character encodings. If the index is out of range, the function should return an error message. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python def get_character_at_index(string: str, index: int) -> str: """ Returns the character at the given index in the string. If the index is out of range, returns an error message. Args: string (str): The input string fr...
python_sharegpt_23k
1,263
Write a Python function to sort an array of positive and negative integers from smallest to largest using the bubble sort algorithm while preserving the relative order of duplicate elements. The function should be optimized to minimize unnecessary comparisons and swaps, and it should handle large arrays with up to 1 mi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort_preserve_order(arr: List[int]) -> List[int]: """ Sorts an array of positive and negative integers using the bubble sort algorithm, preserving the relative order of duplicate elements....
python_sharegpt_23k
1,267
Write a Python function to remove all duplicates from a given list while maintaining the original order of elements. The function should not use any built-in Python functions or libraries, except for basic list operations like append and iteration. The code should start with: ```python from typing import List def rem...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_maintain_order(input_list: List[int]) -> List[int]: """ Removes all duplicates from the given list while maintaining the original order of elements. Args: input_list (L...