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 Center および File ExchangeMultidimensional Arrays についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by