akshitagit / akshitagit/Python

Mr Y and his Transport Problem

オープン
#104 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
algorithms datastructures DSA good first issue hacktoberfest hacktoberfest2020 hactoberfest
主要言語
Python
スター
124
フォーク
109
PR マージ指標
30日以内にマージされた PR はありません

説明

Mr X has a huge transport business, where his company provides trucks to transfer goods. Mr Y has a manufacturing facility where it has N number of loading areas. Mr Y orders N trucks from Mr X for transportation of each of its manufactured products. One day the trucks were misaligned corresponding to their loading areas. Mr Y wants to swap trucks one by one to place them at their true positions in such a way that there is a minimum number of swaps between trucks. Note that all trucks are already at the misplaced loading area, swap occurs between two trucks at a time and truck is numbered based on its loading area number that is both loading area and truck have the same number and loading area are denoted by 1 to N.

Input:
1 <= N <= 50
1st Line: integer N which denotes the number of loading areas
2nd Line: N space-separated integers denoting truck numbers parked on 1 to N loading area.

Output:
Number denoting a _minimum number of swaps_.

**Sample input**
10
1 3 2 4 9 6 7 5 8 10

**Sample output**
3

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。