I couldn’t understand the brute force method and efficient method time complexity difference... In brute force meth, iterating through every elements doesn’t take O(n) too? :)
In Brute Force method you are iterating over the array again and again to find the element. So you are doing n iterations for n items. Hence, a time complexity of O(n^2) In the efficient method, you only iterate once Hope that helps :)