HackerRank Dot and Cross problem solution in Python YASH PAL, 31 July 202417 January 2026 HackerRank Dot and Cross problem solution in Python – In this Dot and Cross problem, you are given two arrays A and B. Both have dimensions of N X M. Your task is to compute their matrix product.dotThe dot tool returns the dot product of two arrays.import numpy A = numpy.array([ 1, 2 ]) B = numpy.array([ 3, 4 ]) print numpy.dot(A, B) #Output : 11 crossThe cross tool returns the cross product of two arrays.import numpy A = numpy.array([ 1, 2 ]) B = numpy.array([ 3, 4 ]) print numpy.cross(A, B) #Output : -2HackerRank Dot and Cross problem solution in Python 2.import numpy a=int(raw_input()) m=[] n=[] for i in range(a): m.append(map(int,raw_input().split())) for i in range(a): n.append(map(int,raw_input().split())) print numpy.dot(numpy.array(m),numpy.array(n))Dot and Cross problem solution in Python 3.import numpyn=int(input())a = numpy.array([input().split() for _ in range(n)],int)b = numpy.array([input().split() for _ in range(n)],int)m = numpy.dot(a,b)print (m)Problem solution in pypy programming.# Enter your code here. Read input from STDIN. Print output to STDOUTimport numpyn=int(raw_input().strip())a=[]b=[]for i in xrange(n): t=map(int,raw_input().split()) a.append(t)for i in xrange(n): t=map(int,raw_input().split()) b.append(t)a=numpy.matrix(a)b=numpy.matrix(b)print a*bProblem solution in pypy3 programming.# Enter your code here. Read input from STDIN. Print output to STDOUT import numpy as np n= int(input()) a = np.array([input().split() for _ in range(n)],dtype=np.int) b = np.array([input().split() for _ in range(n)],dtype=np.int) res = [] for r in range(n): row = [np.dot(a[r,:],b[:,i]) for i in range(n)] res.append(row) res = np.array(res) print(res) coding problems solutions Hackerrank Problems Solutions Python Solutions HackerRankPython