give zerobased permutation num 0indexe build array ans length ansi numsnumsi 0 numslength return itA zerobased permutation num array distinct integer 0 numslength 1 inclusive Example 1input num 021534output 012453explanation the array an build follow an numsnums0 numsnums1 numsnums2 numsnums3 numsnums4 numsnums5 nums0 nums2 nums1 nums5 nums3 nums4 012453example 2input num 501234output 450123explanation the array an build followsan numsnums0 numsnums1 numsnums2 numsnums3 numsnums4 numsnums5 nums5 nums0 nums1 nums2 nums3 nums4 450123 Constraints1 numslength 10000 numsi numslengthThe element num distinct Followup can solve extra space ie o1 memory