I loop through the array to check if a number is equal to the target
-
Time complexity:O(1)
-
Space complexity:O(N)
function search(nums: number[], target: number): boolean {
for(let i=0;i<nums.length;i++){
if(nums[i]===target){
return true
}
}
return false
};