Improve this: the smallest gap

A code exercise of about 10 minutes: read the statement, solve «Improve this: the smallest gap» in the browser and get a review like in a real interview.

Code · 10 min
Loading…

Statement

This minGap(nums) works: it returns the smallest difference between two numbers in the list (there are at least two). It compares every pair and doesn't finish in time on big lists. Make it fast.