Given an array A of n elements. We need to change the array into a permutation of numbers from 1 to n using minimum replacements in the array.

2 views (last 30 days)
Given an array A of n elements. We need to change the array into a permutation of numbers from 1 to n using minimum replacements in the array.

Accepted Answer

Dinesh Yadav
Dinesh Yadav on 29 Oct 2019
Hi, I am attaching a code file for the above question. Hope it helps.
  1 Comment
Abhishek Bakhla
Abhishek Bakhla on 29 Oct 2019
Edited: Abhishek Bakhla on 29 Oct 2019
Thanks for your help. It worked. I have also done similar to yours instead of while, i used find function for having indicies which are zeros and assigning the same in similar manner.

Sign in to comment.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!