Help with approach

sol: https://ide.codingblocks.com/s/418550

prob:https://hack.codingblocks.com/app/contests/2022/1337/problem

how do I pass array by reference so that the changes from the function are reflected in the array present in main function.

arrays are always pass by reference

mistakes

  1. you have to swap arr[i] and arr[min]
  2. you need index to swap the element not the value of element

your Modified Code

but this will give TLE in one case
because sorting algorithm is not optimised
either use inbuilt sort function or use merge sort or quick sort

Correct code