

Input: N = 5, M = 4, arr =, problemRange =, ,, , ]Įxplanation: values which can be assigned to the students are 12 is assigned to first student who can attempt questions of difficulty level 14 as it is the closest to 14. Print the X value assigned to every student. X values must be assigned to students in their order since the same value of X cannot be assigned to more than one student. In case of a tie between two values closest to arr, a lesser difficulty value must be chosen. The task is to assign a unique integer X from problemRange to every integer in array arr such that | arr – X | is minimized. Given an array problemRange of N pairs having starting and ending values as a range of difficulty levels, and an array arr of size M indicating the difficulty level every student can attempt. Note that the problem chosen for the j-th student may affect problems chosen for all the students tested later, so you have to process students in the same order as they appear in the input.Īs keeping track of all the problems can be fairly complicated, can you help Edsger and determine which problems he should give to all of his students? In case of ties, Edsger will always choose the easier problem. Therefore, Edsger will choose for the j-th student a problem of difficulty Pj, in a way that |Pj−Sj| is minimal and a question of difficulty Pj was not already given to any of the students before the j-th student. Unfortunately, this is not always possible, as Edsger may have not prepared a problem of this difficulty, or he may have already asked this problem to some other student earlier. Through countless lectures, exercises, and projects, Edsger has gauged student number j to have skill level Sj and wants to give that student a problem with difficulty Sj. No two students can get the exact same problem, so when Edsger tests a student with some problem, he cannot use this problem anymore. He wants to test each student with exactly one problem from one of his sets. This semester Edsger has to test M students. Find Second largest element in an array.

Sliding Window Maximum (Maximum of all subarrays of size k).Find subarray with given sum | Set 1 (Nonnegative Numbers).k largest(or smallest) elements in an array | added Min Heap method.Program to find largest element in an array.Queue | Set 1 (Introduction and Array Implementation).Search an element in a sorted and rotated array.Array of Strings in C++ (5 Different Ways to Create).Count Inversions in an array | Set 1 (Using Merge Sort).Python | Using 2D arrays/lists the right way.K'th Smallest/Largest Element in Unsorted Array | Set 1.Maximum and minimum of an array using minimum number of comparisons.Given an array A and a number x, check for pair in A with sum as x.Stack Data Structure (Introduction and Program).Write a program to reverse an array or string.ISRO CS Syllabus for Scientist/Engineer Exam.ISRO CS Original Papers and Official Keys.GATE CS Original Papers and Official Keys.
