Hey the solution looks good, just that the time complexity will be O(nlogn) as you have sorting even though the while loop takes only O(n) to find the solution