Skip to content

Tag: time-complexity

time complexity of concatenating strings in python

What is is the time complexity for the following function in Python? The function takes two inputs, string1 and string2, concatenates them together using “+” and returns the concatenated string. is it O(n + m) where n is the length of string1 and m is the length of string2? thanks! Answer Yes, it …

Power Plant – solve the problem in O(nlogn)

I had the following problem on the exam: A certain power plant needs coal to operate, so it has ordered n deliveries, and information about each delivery (number of tons) is stored in a list A. The delivered coal is stored in warehouses with consecutive numbers 0, 1, …. (Their exact number is not given)…