You getting the wrong answer for small test cases, because you have to type cast the value when storing it to long long prod like you just have to replace long long prod = arr[i] * arr[j]; by long long prod = (long)arr[i] * arr[j]; But still this is brute force solution, ...
It might be useful for data analysis or mapping. It's unlikely that an ad-hoc solution can be developed during an interview and two algorithms to look out for in the candidate’s solution are Graham's scan and Jarvis's march. Questions like these allow a recruiter or hiring manager to ...