Comments

In Honest Coach editorial i think that this code block is not necessary.

for (int i = 0; i < n; i++) {
	for (int j = i + 1; j < n; j++) {
		result = min(result, a[j] - a[i]);
	}
}

Since we've sorted the vector. When we slice it in the i'th position, maximum of left array would be (i-1)'th element and minimum of right array would be i'th element so that doing it in one iteration is enough.

for (int i = 1; i < n; i++) {
	result = min(result, a[i] - a[i-1]);
}

Please correct me if i'm wrong