Oracle OA
Oracle OA
Maxlmum Knowledge
There Is golng to be a conference for d days. The
schedule of nmeetings is glven as three arrays, s
(star) e (end), and a (additional knowledge galned).
The fh meeting Is avalable from (sU,eldays (both
Incluslve) and provides a knowledge galn of al). A
limit of kmeetings can be attended in one day.
Find the maxlmum knowledge that can ba,galned Jn
a day.
Example
de 10
n=4
k=2
S= 25,4, 3)
e (8, 9, 7,5]
8-[800, 1600, 200, 400
BETA) Can't read the text? Switch theme
22. Question 22
Dtample
n=4
popularity-B41,2)
Function Description
Complete the function minimumSwaps in the
editor below.
7Sample Case 0
Sample Input 0
STDIN Function I
3 popularity[] size n = 3
3 popularity = (3, 1, 2]
1
Sample Output 0
1
Explanation 0
n=3
popularityB1,2]
sort(v.begin(),v.end():
priority_queue<int,vector<int>,greater<int>> pq;
int i-0,day=v[o][o];
int ans=0;
while(i<n or pq.size)){
if(pq.size()==0) day=v[i](0);
while(i<n and v[il[0]<=day){
pq.push(v[l[1);
itt;
int cnt-0;
day++;
if(day>d) break;
return ans;
2nd
int minSwaps(int arrl], int n)
int len = n;
map<int, int> map;
for (int i= 0; i< len; i++)
map[nums[i]] = i;
}
return ans;