Given a string S and array of strings, find whether the array contains a string with one character different from the given string.
 
Example 1:
Input :
N = 4
arr[] = {"bana","apple","banaba","bonanzo"}
S = "banana"
Output :
True
Explanation: 
banana and banaba has only one character 
different.
Example 2:
Input:
N = 4
arr[] = {"bana","apple","banaba","bonanzo"}
S = "apple"
Output :
False
Explanation: 
No string in arr differ by one 
character from S 
 
 Your Task:  
You don't need to read input or print anything. Your task is to complete the function isStringExist() which takes the string array arr[], its size N and a string S as input parameters and returns "True" if a string exists in arr which has only one character different from S else return "False".
 
Expected Time Complexity: O(N*Length of the string S)
Expected Space Complexity: O(1)
 
Constraints :
1 ≤ N ≤ 100
1 ≤| arr[i] | ≤ 1000
1 ≤| S | ≤ 1000

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(N*Length of the string S)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3
class Solution:
    def isStringExist (self, arr, N, S):
        # code here 

Solutions:
class Solution:

	def isStringExist(self, arr, N, S):
		ans = False
		for item in arr:
			if len(item) == len(S):
				R = 0
				for (i, v) in enumerate(item):
					if S[i] == v:
						R += 1
				if len(S) - R == 1:
					ans = True
				R = 0
		return ans


class Solution:

	def isStringExist(self, arr, N, S):
		for i in range(N):
			count = 0
			if len(arr[i]) == len(S):
				for j in range(len(arr[i])):
					if S[j] != arr[i][j]:
						count += 1
			if count == 1:
				return True
		return False


class Solution:

	def isStringExist(self, arr, N, s):
		for i in range(len(arr)):
			diff_count = 0
			if len(arr[i]) == len(s):
				for j in range(len(s)):
					if arr[i][j] != s[j]:
						diff_count += 1
					if diff_count > 1:
						break
				if diff_count == 1:
					return True
		return False


class Solution:

	def isStringExist(self, arr, n, s):
		l = len(s)
		for i in arr:
			count = 0
			if len(i) == l:
				for j in range(len(i)):
					if i[j] != s[j]:
						count += 1
			if count == 1:
				return True
		return False


class Solution:

	def isStringExist(self, arr, N, S):

		def helper(word, target):
			n = len(word)
			m = len(target)
			if n != m:
				return False
			ans = 0
			for i in range(n):
				if word[i] != target[i]:
					ans += 1
			if ans == 1:
				return True
			return False
		for i in arr:
			if helper(i, S):
				return True
		return False


class Solution:

	def isStringExist(self, arr, N, S):
		l = 0
		for i in range(N):
			if len(arr[i]) == len(S):
				k = 0
				l = 0
				for j in range(len(arr[i])):
					if arr[i][j] == S[k]:
						k += 1
						continue
					else:
						l += 1
						k += 1
				if l == 1:
					return True
		return False


class Solution:

	def isStringExist(self, arr, N, S):
		a = []
		for i in arr:
			if len(i) == len(S):
				a.append(i)
		for i in a:
			c = 0
			for j in range(len(i)):
				if i[j] != S[j]:
					c += 1
			if c == 1:
				return True
		return False


class Solution:

	def isStringExist(self, arr, N, S):
		n = len(S)
		for j in range(N):
			size = len(arr[j])
			if abs(size - n) > 0:
				continue
			word = arr[j]
			word_diff = 0
			for i in range(size):
				if word_diff > 1:
					break
				if word[i] != S[i]:
					word_diff += 1
			if word_diff == 1:
				return True
		return False


class Solution:

	def isStringExist(self, a, n, s):
		a = []
		for i in arr:
			if len(s) == len(i):
				a.append(i)
		for i in a:
			c = 0
			for j in range(len(i)):
				if i[j] != s[j]:
					c += 1
			if c == 1:
				return True
		return False


class Solution:

	def isStringExist(self, arr, N, s):
		n = len(s)
		for i in arr:
			if len(i) != n:
				continue
			index = 0
			diff = 0
			for j in i:
				if j != s[index]:
					diff += 1
				index += 1
			if diff == 1:
				return True
		return False


class Solution:

	def isStringExist(self, arr, N, S):
		for i in arr:
			if len(i) != len(S):
				continue
			count = False
			for j in range(len(S)):
				if i[j] != S[j]:
					if count == False:
						count = True
					else:
						count = False
						break
			if count:
				return True
		return False


class Solution:

	def isStringExist(self, arr, N, S):
		res = [x for x in arr if len(x) == len(S)]
		r = []
		for i in res:
			wr = 0
			for x in range(len(i)):
				if i[x] != S[x]:
					wr += 1
			if wr == 1:
				r.append(i)
		return True if len(r) > 0 else False


class Solution:

	def isStringExist(self, arr, N, S):
		l = len(S)
		c = 0
		for i in arr:
			c = 0
			if len(i) == l:
				for j in range(len(i)):
					if i[j] != S[j]:
						c += 1
			if c == 1:
				return True
		return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		arr = input().split()
		S = input()
		ob = Solution()
		print(ob.isStringExist(arr, N, S))


class Solution:

	def isStringExist(self, arr, N, S):
		size_S = len(S)
		for word in arr:
			size_word = len(word)
			if size_word == size_S:
				count = 0
				for i in range(size_word):
					if S[i] != word[i]:
						count += 1
						if count > 1:
							break
				if count == 1 or count == 0:
					return True
		return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		arr = input().split()
		S = input()
		ob = Solution()
		print(ob.isStringExist(arr, N, S))


class Solution:

	def isStringExist(self, arr, N, S):
		lst = list(S)
		for itr in range(N):
			if len(arr[itr]) != len(lst):
				continue
			count = 0
			for itr2 in range(len(lst)):
				if arr[itr][itr2] != lst[itr2]:
					count += 1
			if count == 1:
				return True
		return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		arr = input().split()
		S = input()
		ob = Solution()
		print(ob.isStringExist(arr, N, S))


class Solution:

	def isStringExist(self, arr, N, S):
		i = 0
		x = 0
		y = 0
		slen = len(S)
		c = 0
		while x < N:
			o = len(arr[x])
			if slen == o:
				while i < slen and y < o:
					if S[i] != arr[x][y]:
						c += 1
						y += 1
						i += 1
					else:
						y += 1
						i += 1
			i = 0
			x += 1
			y = 0
			if c == 1:
				return True
			c = 0
		return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		arr = input().split()
		S = input()
		ob = Solution()
		print(ob.isStringExist(arr, N, S))


class Solution:

	def isStringExist(self, arr, N, S):
		s = list(S)
		l = len(s)
		c = 0
		for i in range(N):
			if len(arr[i]) == l:
				l1 = list(arr[i])
				for i in range(len(l1)):
					if l1[i] != s[i]:
						c = c + 1
				if c == 1:
					return True
			c = 0
		return False


class Solution:

	def isStringExist(self, arr, n, s):
		length = len(s)
		for word in arr:
			if len(word) == length:
				c = 0
				for i in range(length):
					if s[i] != word[i]:
						c += 1
						if c > 1:
							break
				else:
					if c == 1:
						return True
		return False


class Solution:

	def isStringExist(self, arr, N, S):
		m = len(S)
		l = []
		for x in arr:
			if len(x) == m:
				l.append(x)
		count1 = []
		for x in l:
			c = 0
			i = 0
			while i < len(x):
				if x[i] == S[i]:
					i += 1
				else:
					c += 1
					i += 1
			count1.append(c)
		if 1 in count1:
			return True
		return False


class Solution:

	def isStringExist(self, words, N, target):

		def mismatch_1(word, target):
			if word == target:
				return False
			else:
				count = 0
				for i in range(len(word)):
					if word[i] != target[i]:
						count += 1
					if count > 1:
						return False
			return True
		for word in words:
			if len(word) != len(target):
				pass
			else:
				res = mismatch_1(word, target)
				if res == False:
					pass
				else:
					return res
		else:
			return False


class Solution:

	def isStringExist(self, arr, N, S):
		if S in arr:
			return False
		else:
			for j in arr:
				count = 0
				if len(j) == len(S):
					tup = zip(list(j), list(S))
					for (k, l) in tup:
						if k != l:
							count += 1
				if count == 1:
					return True
			else:
				return False


class Solution:

	def isStringExist(self, arr, N, S):
		for item in arr:
			if len(item) != len(S):
				continue
			common_letter = 0
			for letter in range(len(S)):
				if item[letter] == S[letter]:
					common_letter += 1
			if abs(len(S)) - abs(common_letter) == 1:
				return True
		return False


class Solution:

	def isStringExist(self, arr, N, S):
		c = 0
		for i in arr:
			if len(i) == len(S):
				c = 0
				for j in range(len(i)):
					if i[j] == S[j]:
						continue
					c += 1
				if c == 1:
					break
		if c == 1:
			return True
		else:
			return False