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 removecharacters.py
Write a function removecharactersinputstring, toremove that takes two inputs:
inputstring : a string
toremove: a string
and returns a string that is exactly the same as the inputstring but without any of the characters in toremove. Your function must have a running time complexity of where represents the length of inputstring.
For clarity, let be the length of toremove. Your code cannot have a running time complexity of to receive full credit, it must be
NOTE: you may not use any builtin string removal methodsfunctions in your code eg strstrip
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.
newstring removecharactersabcdc
print newstring
abd
Problem anytwosum.py
Write a function anytwosum 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 where 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 anytwosum
print result
True
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
