+ 1

Python End Short

Can someone please help me understand the following question? Given a list A of N distinct integer numbers, you can sort the list by moving an element to the end of the list. Find the minimum number of moves required to sort the list using this method in ascending order.  Input Format: The first line of the input contains N distinct integers of list A separated by a space. Output Format Print the minimum number of moves required to sort the elements. Example: Input: 1 3 2 4 5 Output: 3 Explanation: In the first move, we move 3 to the end of the list. In the second move, we move 4 to the end of the list, and finally, in the third movement, we move 5 to the end. https://code.sololearn.com/cJfWwD08Qb9e/?ref=app

5th Mar 2019, 9:32 AM
Nilutpol Kashyap
Nilutpol Kashyap - avatar
6 odpowiedzi
+ 3
1 3 2 4 5 - input 1 2 4 5 3 - 3 moved to the end 1 2 5 3 4 - 4 moved to the end 1 2 3 4 5 - 5 moved to the end Total number of moves: 3
5th Mar 2019, 10:58 AM
Pedro Tortello
Pedro Tortello - avatar
+ 1
Tortello I have written the code. can u please help me further. it still showing some errors
7th Mar 2019, 6:31 AM
Nilutpol Kashyap
Nilutpol Kashyap - avatar
7th Mar 2019, 6:31 AM
Nilutpol Kashyap
Nilutpol Kashyap - avatar
+ 1
Jay Matthews sir can u please help. I have uploaded a code.
7th Mar 2019, 10:30 AM
Nilutpol Kashyap
Nilutpol Kashyap - avatar
+ 1
Nilutpol Kashyap Line 6 "while l:" will enter in an infinite loop. Also, "min" is a built-in method that returns the smallest element in an iterable or 2+ parameters. You should avoid it as a variable name.
7th Mar 2019, 11:48 PM
Pedro Tortello
Pedro Tortello - avatar
+ 1
thanks a lot sir Tortello
8th Mar 2019, 3:07 AM
Nilutpol Kashyap
Nilutpol Kashyap - avatar