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)
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