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

INFEED

Ds contest 1.1 Mar 29

Session 1:

1. A.

2. D 

3. C 

4. A 

5. B 

6. B 

7. D 

8. C 

9. B 

10. D 

Session 2:

Program 

1.Problem Statement Numeros the Artist had two lists that were permutations of one another. He was very proud. Unfortunately, while transporting them from one exhibition to another, some numbers were lost out of the first list. Can you find the missing numbers? Notes · If a number occurs multiple times in the lists, you must ensure that the frequency of that number in both lists is the same. If that is not the case, then it is also a missing number. · You have to print all the missing numbers in ascending order. Print each missing number once, even if it is missing multiple times. The difference between maximum and minimum number in the second list is less than or equal to 100. Input Format There will be four lines of input:


• n the size of the first list arr, The next line contains n space-separated integers arri. - m the size of the second list brr, The next line contains m space-separated integers brri. Output Format Output the missing numbers in ascending order.

C++ program:

#include<bits/stdc++.h>

using namespace std;


int main(){


 int n,m,a,mx = -99999,mn = INT_MAX;

 int res[1000011] = {0};


    cin >> n;

 for(int i = 0; i < n; i++){

        cin >> a;

        res[a]--;

    }

    cin >> m;

 for(int i = 0; i < m; i++){

        cin >> a;

        res[a]++;

 if(a < mn)mn = a;

 if(a > mx)mx = a;

    }

 for(int i = mn; i <= mx; i++)if(res[i] > 0)cout << i << " ";

 return 0;

}


2. 

Problem Statement This is a simple challenge to get things started. Given a sorted array (arr) and a number (V), can you print the index location of V in the array? Input Format The first line contains an integer, V, a value to search for. The next line contains an integer, n, the size of arr. The last line contains n space-separated integers, each a value of arri where O<=i<n). Output Format Output the index of V in the array.

Python 3:

a=int(input())

b=int(input())

c=list(map(int,input().split()))

print(c.index(a))












Post a Comment

Previous Post Next Post