coding-quiz-3
---
id: coding-quiz-3
title: Coding Quiz - Check for Value Existence
description: Write a function to check the existence of a specific data element within a linked list.
tags:
- Python
- Algorithm
- Search
- Linked List
sidebar_position: 6
isPublic: false
---
# 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.
<br />
```python title="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
data
list consists of integers. -
target
is 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
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.