This is a linear search problem where in we check for index value and element at that index.It is not O(1) as it is not constant which is independent of the input size,here the above problem is dependent on the input size hence it cannot be O(1).
O(logn) is possible as we can do binary search to find elements but it is not tightest upper bound hence O(n)