diff --git a/285C - Beautiful Permutation.cpp b/285C - Beautiful Permutation.cpp new file mode 100644 index 0000000..0e906bf --- /dev/null +++ b/285C - Beautiful Permutation.cpp @@ -0,0 +1,38 @@ +/* +*Problem Name (C. Building Permutation) +*Problem Statement :- +You have a sequence of integers a1, a2, ..., an. In one move, you are allowed to decrease or increase any number by one. +Count the minimum number of moves, needed to build a permutation from this sequence. +*/ + +#include +using namespace std; +typedef long long ll; + +int main(){ + + ll n;cin>>n; // ll is long long data type as defined above + ll arr[n]; + for(ll i=0; i>arr[i]; + } + + sort(arr,arr+n); //first we sort the array + ll diff =0, sum =0; + + for(ll i=0; i