Hi all,
Sharing the two questions I encountered during my SWE Intern OA, platform was on HackerRank and time limit is 60 minutes for 2 questions. Was able to solve the first one but didn't have sufficient time for the second time (not sure whether I was correct as well), will be glad if anyone can give some hint regarding q2.
(1) The Largest Element
We are supposed to find out absolute difference of these distinct values, and since the absolute difference must be within the range of min(arr) and max(arr). If we want to retrieve the Kth largest element, we can do max(arr)-K if K is less than max(arr).

(2) Minimum Cost Connections
Didn't have enough time to figure out the solution (I'm not too good at solving graph/dp questions also), was trying to do backtracking but probably will get TLE as well, felt like I've seen this question somewhere before but still wasn't able to solve it. Would be great if someone can give me some directions for this question.

Input follows the input format.
5
12 7 8 24 2 7
6 5 12 4 8 7
5
1 2
2 3
4 2
5 4
Ans: (7+6)[From City 6 to City 1] + (7+8)[From City 6 to City 5] = 13 + 15 = 28
