• + 3 comments

    I don't think both are same. Sorting makes it solution complex(considering we are not using in-built sorting method). Also sorting will give nlogn complexity and finding min and max in next loop makes O(n) + O(nlogn) = O(nlogn) total complexity of this solution. Correct me if I am wrong.