Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

The pair with average

Instructions

Given sorted list of integers and target average implement a function which determine if there is a pair of values in the list where their average equals target average.

Challenge | Solution

Examples

hasAverage(listOf(), 1.0) // false

hasAverage(listOf(3, 4, 7, 9), 6.5) // true

hasAverage(listOf(3, 4, 7, 9), 3.0) // false

hasAverage(listOf(3, 5, 9, 7, 11, 14), 8.0) // true

Hints

Hint 1 Use double pointer