减少O(n ^ 2)对数的时间复杂度

问题描述 投票:0回答:1

我已将以下代码提交给面试评估,但是由于运行代码需要花费时间,因此它未能通过所有测试。所以请您帮我改善代码的时间复杂度。

代码说明:

enter image description here

def jobOffers(scores, lowerLimits, upperLimits):
count = 0
array = []
d1 = {}
for i in range(len(lowerLimits)):
    for j in range(len(scores)):
        if scores[j] >= lowerLimits[i] and scores[j] <= upperLimits[i]:
            count += 1
        else:
            pass
    array.append(count)
    count -= count
return array
time runtime complexity-theory
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.