Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

Coding Challenge solutions April 15

First Program: 

Problem Statement Write a program to nd whether 2 arrays are the same. Input Format Input

consists of 2n+1 integers. The rst integer corresponds to ‘n’ , the size of the array. The next ‘n’

integers correspond to the elements in the rst array. The next ‘n’ integers correspond to the

elements in the second array. Assume that the maximum value of n is 15. Output Format Print yes if

the 2 arrays are the same. Print no if the 2 arrays are different.


PROGRAM IN PYTHON:

a=int(input())
b=[]
c=[]
for i in range(a):
  b.append(int(input()))
for j in range(a):
  c.append(int(input()))
if(b==c):
  print("yes")
else:
  print("no")

Second Program:

Problem Statement Write a program to nd the number of distinct elements in a sorted array.
Input Format Input consists of n+1 integers. The rst integer corresponds to n, the number of
elements in the array. The next n integers correspond to the elements in the array. Assume that the
maximum value of n is 15. Output Format Output consists of a single integer which corresponds to
the number of distinct elements in the array.

PROGRAM IN PYTHON:

a=int(input())
b=[]
for i in range(a):
  b.append(int(input()))
print(len(set(b)))

Post a Comment

Previous Post Next Post