JAVA (1.8)
Min swaps
Nikhil’s birthday is coming on 8’th March.
His friend Vivek is planning to throw a surpr

Question

JAVA (1.8)
Min swaps
Nikhil’s birthday is coming on 8’th March.
His friend Vivek is planning to throw a surprise party without his knowledge, so he make a plan to call all
Nikhil’s friend to Toit restaurant.
He came up with an idea of sitting plan at restaurant in such a way that the person with lowest friendship
sits in starting and a person with highest in the end.
Two or more persons can have same level of friendship.
Nikhil’s friends are sitting randomly and vivek can bribe every friend with a candy and only swap two
adjacent friends.
Vivek is busy in other arrangement too so, he check the first and last person’s friendship level to confirm
the seating arrangement.
So Vivek wants to calculate the minimum candies need to make all look good.
Input:
T denoting number of test cases.
Then T test cases follow each containing a number N denoting number of friends.
Next line contains N friends having their friendship level.
Output:
2
3 * NOTE : C
4
5
6 – import java
7 import java
8- class Main
public
10
Lis
11
try
12
13
14
15
16 –
17
18
19
20
21
22
} ce
23
24
25
26 }
}
}
Output the minimum candies it would take to complete the task.
Constraints
1 <=T<= 500
1<=N<= 100000
1 <=M<= 100000​

in progress 0
Kinsley 2 years 2021-06-24T13:10:51+00:00 1 Answers 1 views -1

Answers ( )

    0
    2021-06-24T13:12:32+00:00

    Answer:

    pagal Ham Hain Ham hain pagal Ham pagal nahin hai bhaiya Hamara dimag kharab hai

Leave an answer

Browse

9:3-3+1x3-4:2 = ? ( )