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