findPairOfSum

fun IntArray.findPairOfSum(sum: Int): Pair<Int, Int>?

finds two numbers inside the Array from the given sum.

Example:

arrayOf(1..10).findPairOfSum(10) // (1, 9)

Since

1.1.0

See also


fun LongArray.findPairOfSum(sum: Long): Pair<Long, Long>?

finds two numbers inside the Array from the given sum.

Example:

arrayOf(1..10L).findPairOfSum(10L) // (1L, 9L)

Since

1.1.0

See also


fun FloatArray.findPairOfSum(sum: Float): Pair<Float, Float>?

finds two numbers inside the Array from the given sum.

Example:

arrayOf(1F, 2F, 3F, 4F, 5F).findPairOfSum(3F) // (1F, 2F)

Since

1.1.0

See also


fun DoubleArray.findPairOfSum(sum: Double): Pair<Double, Double>?

finds two numbers inside the Array from the given sum.

Example:

arrayOf(1.0, 2.0, 3.0, 4.0, 5.0).findPairOfSum(3.0) // (1.0, 2.0)

Since

1.1.0

See also


fun IntArray.findPairOfSum(sum: Int): Pair<Int, Int>?

finds two numbers inside the IntArray from the given sum.

Example:

intArrayOf(1..10).findPairOfSum(10) // (1, 9)

Since

1.1.0

See also


fun LongArray.findPairOfSum(sum: Long): Pair<Long, Long>?

finds two numbers inside the LongArray from the given sum.

Example:

longArrayOf(1..10L).findPairOfSum(10L) // (1L, 9L)

Since

1.1.0

See also


fun FloatArray.findPairOfSum(sum: Float): Pair<Float, Float>?

finds two numbers inside the FloatArray from the given sum.

Example:

floatArrayOf(1F, 2F, 3F, 4F, 5F).findPairOfSum(3F) // (1F, 2F)

Since

1.1.0

See also

floatArrayOf

fun DoubleArray.findPairOfSum(sum: Double): Pair<Double, Double>?

finds two numbers inside the DoubleArray from the given sum.

Example:

doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0).findPairOfSum(3.0) // (1.0, 2.0)

Since

1.1.0

See also

doubleArrayOf

fun Iterable<Int>.findPairOfSum(sum: Int): Pair<Int, Int>?

finds two numbers inside the Iterable from the given sum.

Example:

listOf(1..10).findPairOfSum(10) // (1, 9)

Since

1.1.0

See also


fun Iterable<Long>.findPairOfSum(sum: Long): Pair<Long, Long>?

finds two numbers inside the Iterable from the given sum.

Example:

listOf(1..10L).findPairOfSum(10L) // (1L, 9L)

Since

1.1.0

See also


fun Iterable<Float>.findPairOfSum(sum: Float): Pair<Float, Float>?

finds two numbers inside the Iterable from the given sum.

Example:

listOf(1F, 2F, 3F, 4F, 5F).findPairOfSum(3F) // (1F, 2F)

Since

1.1.0

See also


fun Iterable<Double>.findPairOfSum(sum: Double): Pair<Double, Double>?

finds two numbers inside the Iterable from the given sum.

Example:

listOf(1.0, 2.0, 3.0, 4.0, 5.0).findPairOfSum(3.0) // (1.0, 2.0)

Since

1.1.0

See also