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 次查看(过去 30 天)
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.

采纳的回答

Dinesh Yadav
Dinesh Yadav 2019-10-29
Hi, I am attaching a code file for the above question. Hope it helps.
  1 个评论
Abhishek Bakhla
Abhishek Bakhla 2019-10-29
编辑:Abhishek Bakhla 2019-10-29
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by