Transpose and Flatten in HackerRank

 import numpy


m,n =map(int,input().split())

arr = numpy.array([input().split() for i in range(m)],int)
print (arr.transpose())
print(arr.flatten())

Sample input :
2 2 -->size of array
1 2
3 4
output:
[[1 3]
 [2 4]]  -->transpose output
[1 2 3 4] --> flatten output

Comments

Popular posts from this blog

Mean, Var, and Std in numpy HackerRank

Min and Max in numpy HackerRank

Collections.deque() HackersRank Solution