FunctionRacerProblemsRace

Can Make Arithmetic Progression

EasySorting and searchingPython, JavaScript, TypeScript, Java, C++

An arithmetic progression is a list where the difference between every two neighbouring items is the same. Return True if the items of arr can be reordered to form one, otherwise False.

Example 1

arr [3,5,1]
returns true

Reorder to 1, 3, 5: difference 2 each time.

Example 2

arr [1,2,4]
returns false

No order has equal gaps.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Sorting and searching problems