← Back to challenges

A Simple Pair

JavaScriptHardalgebrainterviewmathnumbers

Instructions

Mubashir needs your help to write a simple algorithm of multiplication.

Given an array of integers arr and an integer n, find out a pair of numbers [x, y] from a given array such that **x * y = n **.

If the pair is not found, return null.

Examples

simplePair([1, 2, 3], 3) ➞ [1, 3]

simplePair([1, 2, 3], 6) ➞ [2, 3]

simplePair([1, 2, 3], 9) ➞ null

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Microwave Buttons