Fastest way to check if a value exists in a list

后端 未结 12 2097
猫巷女王i
猫巷女王i 2020-11-22 00:18

What is the fastest way to know if a value exists in a list (a list with millions of values in it) and what its index is?

I know that all values in the list are uniqu

12条回答
  •  走了就别回头了
    2020-11-22 00:46

    Code to check whether two elements exist in array whose product equals k:

    n = len(arr1)
    for i in arr1:
        if k%i==0:
            print(i)
    

提交回复
热议问题