1
00:00:00,080 --> 00:00:00,980
Welcome back.

2
00:00:00,980 --> 00:00:06,440
Let's now try to write the pseudocode for the approach that we have discussed in the previous video.

3
00:00:06,440 --> 00:00:14,630
So as we have discussed, the first step is to sort the costs array on the basis of the difference between

4
00:00:14,630 --> 00:00:17,810
the elements in each element, which in itself is an array.

5
00:00:17,810 --> 00:00:25,760
So we would sort the cost array in ascending order on the basis of costs at the element at index I,

6
00:00:25,760 --> 00:00:29,810
at index zero minus cost at I at index one.

7
00:00:29,810 --> 00:00:30,200
Okay.

8
00:00:30,200 --> 00:00:37,430
So once we are done with this, out of the two n people that we have, we would send the first n people

9
00:00:37,430 --> 00:00:42,200
to city A and the remaining n people to city B, so that's it.

10
00:00:42,200 --> 00:00:44,390
So this is the way that we're going to solve this.

11
00:00:44,390 --> 00:00:50,900
And again, because the question asks us to return the cost involved, we just need to compute the cost

12
00:00:50,900 --> 00:00:57,440
for this and add the cost for this as well to this and finally return the overall cost.

13
00:00:57,440 --> 00:01:00,650
So this is the approach that we will take to solve this question.
