Avg stipend per month: 40,000 - 50,000rs
Location: Bangalore
Job Role: 2023 Summer Internship
Job Link: Apply here for the internship role
Given an array arr of size n, you have to apply the following operation(s): Take a subarray of size k. If this subarray is odd, you have to choose the minimum element in it and if the subarray is even, you have to choose the maximum element (i.e., subarray 0123....k-1 is the first odd subarray and 123...k is the first even subarray and so on). Apply the same operations on this array of selected numbers until a single element is left.
Example
arr = {9,10,19,14,11} and k=3
After first operation, arr = {9,19,11}
Then arr={9}
Constraints:
There are n students, each needing arr[i] for a project they are going to make. They are paired into m inclusive-pairs (a student may appear in more than a single pair). You are the VP of a startup and you have to fund these pairs. There are q queries and you have to answer the maximum number of students you can fund with the amount q[j]. If a student has been previously received funds as part of another pair, they won't be funded again.
I tried something for the first question here:
I believe the time complexity would be around O((nlogn)logn). Please correct me if I'm wrong. E: i think the time complexity is wrong and should be O(n*nlogn). The solution provided is just an implementation used on the leetcode question:
https://leetcode.com/problems/sliding-window-maximum/description/
time complexity for first question is nLog(n)
Explaination:
we can find min-max array using sliding window with 2 priority_queue in O(N*LOG(N)) TC if N in number of element present in original array
O( n log(n))---- first iteration for finding min-max array
O( n/k log(n/k) )----- second iteration for finding 2nd min-max array
O( n/(k*k) log(n/(k*k)) )----- third iteration for finding 3nd min-max array
.. ..... ......................................................
O(1 log(1)) -- final iteration
Over all TC : O(2nlog(n) Approx