To get minimum skew value, we have to keep all the tall books in one shelf.
So, I sort the lengths of books in both the shelves.
Now using the loop I find out which shelf has more tall books.
The outer loop runs for n times which denotes how many books I can keep in one shelf.
I will move the tall books from the shelf which has less tall books to the shelf which has more tall books to get minimum moves.
One denotes no of tall books in shelf one.
Two denotes no of tall books in shelf two.
min(one,two)==k denotes that I can move no more books from the shelf with minimum no of tall books to shelf with maximum no of tall books.
Lets consider the case in which one in minimum .
- I will move books from shelf one to shelf ...