Insertion Sort Advanced Analysis

  • + 0 comments

    The provided template should not expect us to return int. Imagine the case n, n-1, n-2, n-3, ..., 1 , it will require us n*(n - 1) / 2 swap aka will overflow if you use int for n = 1e5. Converted the return type for the provided code to long solved the problem