Array Contains Value - aloalgo

Array Contains Value

Very Easy

You are given an array of integers nums and an integer target.

Your task is to determine if target exists in the array nums.

You may assume that:

  • The array may be empty.
  • The array may contain duplicate values.

Return true if target is found in nums, otherwise return false.

Example 1

Inputs
nums = [1, 2, 3, 4, 5]
target = 3
Output
True
Explanation:

The value 3 is present in the array at index 2.

Example 2

Inputs
nums = [10, 20, 30]
target = 15
Output
False
Explanation:

The value 15 is not present in the array.

Example 3

Inputs
nums = []
target = 1
Output
False
Explanation:

An empty array contains no values.

Loading...
Inputs
nums = [1, 2, 3, 4, 5]
target = 3
Output
True

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!