Search an Element in a Linked List
You are given the head pointer of an acyclic singly linked list and an integer target. Return true if any node contains target; otherwise return false.…
You are given the head pointer of an acyclic singly linked list and an integer `target`. Return `true` if any node contains `target`; otherwise return `false`. Examples serialize node values from **head → tail**. The learner function receives the real `ListNode` head constructed from that transport, not an array.
- `0 <= n <= 10^5`, where `n` is the number of nodes - `-10^9 <= node.val <= 10^9` - `-10^9 <= target <= 10^9` - The list is a proper singly linked list with no cycles.
Example 1: input head = [3,8,1,6,5], target = 1; output true. The value 1 is present at position 2 (0-indexed).
Example 2: input head = [3,8,1,6,5], target = 4; output false. Traversal reaches null without finding 4.
Example 3: input head = [], target = 5; output false. The head is null, so no node can match.
Category: Linked List. Topic: linked-list. Difficulty: Easy. Patterns: linked-list-traversal.