Question: For each question in this homework, you are tasked with implementing a function that: exhibits the correct behavior, and meets the required running time complexity.

For each question in this homework, you are tasked with implementing a function that:
exhibits the correct behavior, and
meets the required running time complexity.
You cannot receive full credit on a problem unless BOTH conditions are met.
Problem 1- remove_characters.py
Write a function remove_characters(input_string, to_remove) that takes two inputs:
input_string : a string
to_remove: a string
and returns a string that is exactly the same as the input_string but without any of the characters in to_remove. Your function must have a running time complexity of O(n), where n represents the length of input_string.
For clarity, let m be the length of to_remove. Your code cannot have a running time complexity of O(mn) to receive full credit, it must be O(n).
NOTE: you may not use any built-in string removal methods/functions in your code (e.g., str.strip()).
Examples
These examples are intended to be illustrative, not exhaustive. Your code may have bugs even if it behaves as below. Write your own unittests to further test expected behaviors.
new_string = remove_characters('abcd','c')
print (new_string)
' abd '
Problem 2- any_two_sum.py
Write a function any_two_sum that takes two inputs:
numbers : a list of integers
total: an integer
and returns True if any two integers in numbers sum to total and False otherwise. Your function must have a running time complexity of O(n), where n represents the length of numbers.
Examples
These examples are intended to be illustrative, not exhaustive. Your code may have bugs even if it behaves as below. Write your own unittests to further test expected behaviors.
result = any_two_sum ([1,3,4,5],7)
print (result)
True
 For each question in this homework, you are tasked with implementing

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!