Is there a difference in O(n) of the below operations?
$a1 = [1=>'',2=>'', 3=>'']
isset($a1[2])
$a2 = [1,2, 3]
in_array(2, $a2)
isset($a1[2])
has complexity of O(1)
in_array(2, $a2)
has complexity of O(3) in your case or in general O(N) where N=count_of_the_array elements
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.