Ladataan tehtävää…
In a permutation, a value can also be used as the address of another element. Given a list nums containing values from 0 to n-1, build a new list ans using the rule ans[i] = nums[nums[i]]. Return the completed list.
[0, 2, 1, 5, 3, 4][0, 1, 2, 4, 5, 3][5, 0, 1, 2, 3, 4][4, 5, 0, 1, 2, 3][0][0]def build_array(nums: list[int]) -> list[int]:
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisään[0,2,1,5,3,4][0,1,2,4,5,3][5,0,1,2,3,4][4,5,0,1,2,3][0][0][1,0][0,1][2,0,1][1,2,0][1,0,1][0,1,0]