Q1. Given an array of integers arr and an integer K. While maintaining the order, split into exactly K pieces such that the sum of maximum of every sub-array is minimum.
For eg:
Sample Input:
arr = [1, 5, 3, 4, 2], K = 2
Output:
6
Possible splits are: [1], [5, 3, 4, 2] | [1, 5], [3, 4, 2] | [1, 5, 3], [4, 2] | [1, 5, 3, 4], [2]
The minimum sum of maximum would be = [1], [5, 3, 4, 2] = 1 + 5 = 6
1 < K <= N <= 300
1 < arr[i] < 10^5
Q2. Given a graph of N nodes named with 1 to N and M bidirectional weighted edges. Find the path from 1 to N such that weight of maximum in the path is minimum and the number of edges in path won’t exceed K.
Sample Input:
N = 4, M = 4, K = 3
Edge 1 <-> 2 = 4
Edge 1 <-> 3 = 2
Edge 2 <-> 4 = 5
Edge 3 <-> 2 = 6
Output
5
Possible routes from 1 to 4 is [1->2->4], [1->3->2->4]
As the maximum in path 1 -> 2 -> 4 is 5 on the edge 2->4, while in 1->3->2->4 is 6 at edge 3->2.
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.
