Annual Day :-
On the eve of the annual day, a competition is held among N students in which each student gains some points based on their performance. All students were asked to stand in a queue in an increasing order based on the points they scored. The clever students stood in a random order so that the students with lower points are not noticed.
You will be given a points array where points[i] tells the teacher the number of points that the ith student earned. Your task is to help the teacher to find all pairs such that for all (0<=i<j<N), the points scored by the ith student is greater than that of the jth student, i.e. points[i]>points[j] where i<j and return the total count of such pairs.
You will be given a points array where points[i] tells the teacher the number of points that the ith student earned. Your task is to help the teacher to find all pairs such that for all (0<=i<j<N), the points scored by the ith student is greater than that of the jth student, i.e. points[i]>points[j] where i<j and return the total count of such pairs.
Input Specification:
input1: An integer value N(1<=N<=1000) denoting the number of students in the class.
input2: An integer array of length N representing the points scored where input2[i] = points scored by ith student and input2[i]<=1000(0<=i<N)
input2: An integer array of length N representing the points scored where input2[i] = points scored by ith student and input2[i]<=1000(0<=i<N)
Output Specification:
Return the total number of pairs that satisfy the constraints given in the problem statement
Example 1:-
input1: 5
input2: {1,1,3,6,2}
Output:-
2
Explanation:-
The pairs of points satisfying the given scenario are:
(3,2) and (6,2).
Hence, 2 is returned as the output.
C++ Code:-
#include<bits/stdc++.h>
using namespace std;
int Student(int input1,int input2[])
{
int count=0;
for(int i=0;i<input1;i++)
{
for(int j=i+1;j<input1;j++)
{
if(input2[i]>input2[j])
count++;
}
}
return count;
}
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
cout<<Student(n,arr);
return 0;
}
Output:-
5
1 1 3 6 2
2
Companies interview:-
- Swap adjacent characters
- Double the vowel characters
- Check valid parenthesis
- Print the characters with their frequencies
- Find closest value
- Word Count
- Program of CaesarCipher
- Program to find the perfect city
- Annual Day | Tech Mahindra coding question
- Find the number of pairs in the array whose sum is equal to a given target.
Wipro :-
- Update the booking ID | Wipro previous year question paper solution
- Pages in PDF
- Find the location id
- Find the odd digits
- Find the Product ID
Infytq :-
Key Points;-
Hackerrank:-
- Python : missing characters : hackerrank solution
- Python : string transformation | Hackerrank solution
- Active Traders certification test problem | Hackerrank Solution
- Usernames changes certification test problem | Hackerrank Solution
- string Representation of objects certification test hackerrank solution
- Average Function | hackerrank certification problem solution
C-tutorial:-
- Micros in C
- Pointer in c
- Function declaration
- Types of user define function
- return type of function
- 2D array
- c program to convert specified days into years weeks and days
- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation
0 Comments