Search
Write a publication
Pull to refresh
0
0
Send message

Использую браузер Brave. По вашей ссылке на получение UserID все значения -- null. Я в безопасности? :)

Извините, но мне показалось, вы просто троллите.

Ваш код выполняется за O(n^2). То, что вложенный цикл начинается с i + 1, на оценку не влияет.

Решение за O(n):

val_to_pos = {x: i for i, x in enumerate(arr)}
for i, x in enumerate(arr):
    pair = target - x
    pair_pos = val_to_pos.get(pair)
    if pair_pos == i and must_be_distinct:
        continue
    if pair_pos is not None:
        return (x, pair)
return None

Information

Rating
Does not participate
Registered
Activity