Hackerrank Zeros and Ones Solution

Hackerrank Zeros and Ones Solution

Solution in python3

Approach 1.

import numpy
N = list(map(int, input().split()))
print(numpy.zeros(N, int))
print(numpy.ones(N, int))

Approach 2.

import numpy
size = tuple(map(int,input().strip().split()))
print( numpy.zeros(size, int) )
print( numpy.ones(size, int) )

Approach 3.

import numpy
N = [int(x) for x in input().split()]
print(numpy.zeros(N, dtype = numpy.int))
print(numpy.ones(N, dtype = numpy.int))

Solution in python

import numpy
N=map(int,raw_input().split())
print numpy.zeros(N,dtype = numpy.int)
print numpy.ones(N,dtype = numpy.int)

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe