Item Price Search

A customer wants to check if a specific item price exists in a list of recorded prices at a provision store. Given the list of prices and a target price, print "Yes" if the target price is present in the array, and "No" otherwise.

A customer wants to check if a specific item price exists in a list of recorded prices at a provision store. Given the list of prices and a target price, print "Yes" if the target price is present in the array, and "No" otherwise.

Input formatLink to this section

  • Line 1: An integer N representing the number of prices
  • Line 2: N space-separated integers representing the prices
  • Line 3: An integer representing the target price to search for

Output formatLink to this section

  • Line 1: "Yes" or "No" based on whether the target price exists in the array

ConstraintsLink to this section

  • 1 <= N <= 100
  • 0 <= price <= 10000
  • 0 <= target <= 10000

tip

Iterate through the array and check if any element matches the target. Keep a boolean flag.

Rate this content

Sign in to rate

Discussion

Sign in to join the discussion