Search Element in Linked List
Singly Linked List: Fundamentals DSA practice problem on Onlearn.
Difficulty: easy.
Topics: How to check if an element is present in a linked list, Linked List, Node, Pointer, Time Complexity, Space Complexity, Loops, Conditional Statements, Linear Search, space complexity, search algorithms, linked list, time complexity analysis, traversal.
Given the head of a singly linked list and an integer val, determine if the integer is present in the linked list. Return true if it is present, or false otherwise. Input Specification: The head of the linked list and an integer value val. Output Specification: Return true if val is found, false otherwise. Sample Test Cases: Example 1: Input: Linked List: 0 1 2 val = 2 Output: true Explanation: The element 2 is present in the list. Example 2: Input: Linked List: 12 5 8 7 val = 6 Output: false Explanation: The list does not contain element 6.