SDE Path

Search an Element in a Linked List

Easy

Search an Element in a Linked List

Determine whether a given value exists within a singly linked list.

Input format

The first line contains N and X. The second line contains the N node values.

Output format

Print true if X occurs in the list, otherwise false.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
5 3
1 2 3 4 5
Expected output
true
Example 2
Input
3 9
1 2 3
Expected output
false