Given a linked list of n nodes and a key , the task is to check if the key is present in the linked list or not.
Example:
Input:
n = 4
1->2->3->4
Key = 3
Output:
True
Explanation:
3 is present in Linked List, so the function returns true.
Your Task:
Your task is to complete the given function searchKey(), which takes a head reference and key as Input and returns true or false boolean value by checking the key is present or not in the linked list.
Constraint:
1 <= n <= 10^{5}
1 <= key <= 10^{5}
Expected Time Complexity: O(n)
Expected Space Complexity: O(1)

Source: geeksforgeeks | Difficulty: EASY

Starter code: #User function Template for python3





''' Node of a linked list

class Node:

    def __init__(self, data):

        self.data = data

        self.next = None

'''

class Solution:

    def searchKey(self, n, head, key):

        #Code here

Solutions:
class Solution:

	def searchKey(self, n, head, key):
		if head is None:
			return 0
		curr = head
		i = 0
		while curr:
			if curr.data == key:
				return 1
			curr = curr.next
		return 0


class Solution:

	def searchKey(self, n, head, key):
		temp = head
		while n:
			if temp.data == key:
				return 1
			temp = temp.next
			n -= 1
		return 0


class Solution:

	def searchKey(self, n, head, key):
		if head == None:
			return 0
		cur = head
		while cur != None:
			if cur.data == key:
				return 1
			cur = cur.next
		return 0


class Solution:

	def searchKey(self, n, head, key):
		curr = head
		for i in range(n):
			if curr.data == key:
				return 1
			else:
				curr = curr.next
		return 0


class Solution:

	def searchKey(self, n, head, key):
		u = []
		while head:
			u.append(head.data)
			head = head.next
		if key in u:
			return 1
		else:
			return 0


class Solution:

	def searchKey(self, n, head, key):
		if head is None:
			return None
		temp = head
		while temp.next:
			if temp.data == key:
				return 1
			else:
				temp = temp.next
		return 0


class Solution:

	def searchKey(self, n, head, key):
		t = head
		while t is not None:
			if t.data == key:
				return 1
			t = t.next
		return 0


class Solution:

	def searchKey(self, n, head, key):
		if not head:
			return 0
		else:
			while head.next:
				if head.data == key:
					return 1
				head = head.next
			return 0


class Solution:

	def searchKey(self, n, head, key):
		cur = head
		count = 1
		if cur.data == key:
			return 1
		while cur.data != key and count != n:
			cur = cur.next
			if cur.data == key:
				return 1
			count += 1
		return 0


class Solution:

	def searchKey(self, n, head, pos):
		curr = head
		while curr != None:
			if curr.data == pos:
				return 1
			curr = curr.next
		return 0


class Solution:

	def searchKey(self, n, head, key):
		curr = head
		bb = 0
		while curr != None:
			if curr.data == key:
				bb = 1
				break
			curr = curr.next
		return bb


class Solution:

	def searchKey(self, n, head, key):
		temp = head
		if head == None:
			return 0
		for i in range(n):
			if temp.data == key:
				return 1
			temp = temp.next
		return 0