{"kind":"task","effective_mode":"full","benchmark":{"kind":"benchmark","effective_mode":"full","slug":"livecodebench","formal_name":"LiveCodeBench","introduction":"LiveCodeBench continuously collects new competitive-programming problems to evaluate coding capabilities. Its initial release_v1 contains 400 problems, with source platform, contest date, and dataset version tracked explicitly.","introduction_ja":"","introduction_en":"","category":"Category not supplied","task_count":null,"acquisition_status":"Acquisition status not supplied","official_url":"https://livecodebench.github.io/","indexing_mode":"noindex","profile":{"resources":[],"task_format":"","scoring":"","metric":"","size":"","answer_access":"","license":"","citation":"","maintainer":"","released":"","why_hard":"","related":[]}},"task_id":"6591465d-10a9-547b-91e4-33feef9dcd76","task_key":"release~5fv1--test--2785","task_revision_id":"1","upstream_id":"2785","short_description":"semi-ordered-permutation","config":"release_v1","split":"test","body":"{\"contest_date\":\"2023-06-04T00:00:00\",\"contest_id\":\"weekly-contest-348\",\"difficulty\":\"easy\",\"platform\":\"leetcode\",\"question_content\":\"You are given a 0-indexed permutation of n integers nums.\\nA permutation is called semi-ordered if the first number equals 1 and the last number equals n. You can perform the below operation as many times as you want until you make nums a semi-ordered permutation:\\n\\nPick two adjacent elements in nums, then swap them.\\n\\nReturn the minimum number of operations to make nums a semi-ordered permutation.\\nA permutation is a sequence of integers from 1 to n of length n containing each number exactly once.\\n \\nExample 1:\\n\\nInput: nums = [2,1,4,3]\\nOutput: 2\\nExplanation: We can make the permutation semi-ordered using these sequence of operations: \\n1 - swap i = 0 and j = 1. The permutation becomes [1,2,4,3].\\n2 - swap i = 2 and j = 3. The permutation becomes [1,2,3,4].\\nIt can be proved that there is no sequence of less than two operations that make nums a semi-ordered permutation. \\n\\nExample 2:\\n\\nInput: nums = [2,4,1,3]\\nOutput: 3\\nExplanation: We can make the permutation semi-ordered using these sequence of operations:\\n1 - swap i = 1 and j = 2. The permutation becomes [2,1,4,3].\\n2 - swap i = 0 and j = 1. The permutation becomes [1,2,4,3].\\n3 - swap i = 2 and j = 3. The permutation becomes [1,2,3,4].\\nIt can be proved that there is no sequence of less than three operations that make nums a semi-ordered permutation.\\n\\nExample 3:\\n\\nInput: nums = [1,3,4,2,5]\\nOutput: 0\\nExplanation: The permutation is already a semi-ordered permutation.\\n\\n \\nConstraints:\\n\\n2 <= nums.length == n <= 50\\n1 <= nums[i] <= 50\\nnums is a permutation.\",\"question_title\":\"semi-ordered-permutation\",\"starter_code\":\"class Solution:\\n    def semiOrderedPermutation(self, nums: List[int]) -> int:\\n        \"}","display_format":"text","language":"","answer_status":"published","assets":[],"source_url":"https://livecodebench.github.io/","history":"initial import","indexing_mode":"noindex","subproblems":[],"grids":[]}