I doubt that it would be worse than the way the Qualcomm camera driver for Android does it. What the hell! https://github.com/tangxunye/android_vendor_qcom_proprietary/blob/e0666c398903d38e72aeda7042ec2836cd3dba68/mm-camera/mm-camera2/media-controller/modules/isp/hw/modules/rolloff/mlro_to_plro/mlro_utils.c
tldr: create an array of absolute values, use a bubblesort function that sorts almost but not quite in place, then return the first item. It's like somebody asked the question in a phone screen and then copy/pasted the solution into their work and called it a day.
earlier there was a reply here "what's wrong with it?" well it's bubble sort which is so inefficient that its no longer taught in CS intro class...
lol no wonder Android is so laggy of developers implement such things...
You seem to be an immature developer. We (mature developers) call this "code reuse". Come and join Microsoft and you'll learn this and many other amazing paradigms!
Dear god why is it using malloc
How big is N? If it's only ever 10 then who gives a shit? Then again.. bubble sort... wow. Even Obama wouldn't use it.
Wow!! Bubble sort? Seriously!!
print out the array. mail it to India. have a sweat shop there where this is all they do. show a progress bar that constantly goes from 0 to 100 while user waits
lol