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 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Dinesh Yadav
Dinesh Yadav el 29 de Oct. de 2019
Hi, I am attaching a code file for the above question. Hope it helps.
  1 comentario
Abhishek Bakhla
Abhishek Bakhla el 29 de Oct. de 2019
Editada: Abhishek Bakhla el 29 de Oct. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by