Skip to content

Commit

Permalink
Added Solution - GfG to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
101rror committed Dec 22, 2024
1 parent 267d4ad commit ccfc233
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#User function Template for python3
class Solution:
def matSearch(self, mat, x):
n = len(mat)
m = len(mat[0])

for i in range(n):
for j in range(m):
if mat[i][j] == x:
return True

return False


#{
# Driver Code Starts
# Initial Template for Python 3

if __name__ == "__main__":
import sys
input = sys.stdin.read
data = input().split()

t = int(data[0])
index = 1
for _ in range(t):
r = int(data[index])
c = int(data[index + 1])
index += 2
matrix = []
for i in range(r):
row = list(map(int, data[index:index + c]))
matrix.append(row)
index += c
x = int(data[index])
index += 1
ob = Solution()
if ob.matSearch(matrix, x):
print("true")
else:
print("false")
print("~")
# } Driver Code Ends

0 comments on commit ccfc233

Please sign in to comment.