Lecture
Coding Quiz - Check for Value Existence
In this coding quiz, your task is to convert a given list data into a Singly Linked List and then write a function to verify if a specific value target exists within the linked list.
The function should accept two arguments: a list of integers data, and the target value target you are looking for.
After constructing the linked list, the function should return True if the target value is found within the list and False if it is not.
Write Code
class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def append(self, value): if self.next is None: self.next = ListNode(value) else: self.next.append(value) def solution(data, target): # Write your code here return
Constraints
-
The
datalist consists of integers. -
targetis a single integer.
Example Input/Output
-
Input:
data = [1, 2, 4, 5],target = 3 -
Output:
False
-
Input:
data = [7, 8, 9],target = 7 -
Output:
True
Previous lessonCoding Quiz - Task SchedulingNext lessonCoding Quiz - Find the First Non-repeating Character
Lessons in this chapter · Review and Deepen Understanding of Python Data Structures
- 1. Review of Key Data Structures
- 2. Multiple-choice quiz
- 3. Fill-in-the-blank quiz
- 4. Coding Quiz - Reverse Words
- 5. Coding Quiz - Task Scheduling
- 6. Coding Quiz - Check for Value Existence
- 7. Coding Quiz - Find the First Non-repeating Character
- 8. What is a Tree?
- 9. Tree Implementation Techniques
- 10. Multiple-choice quiz
- 11. Coding Quiz - Find Minimum Odd Value
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help