filmov
tv
Q6.Find the pair of numbers with smallest difference #javascriptcoding #codinginterviews
Показать описание
🌟 Ready for a challenge?
Practice it using the link in the bio! Go give it a go! 🚀
Question 6: Find the pair of numbers with smallest difference
Difficulty: Medium
Expected Optimal Space & Time Complexity:
O(nlog(n) + mlog(m)) time | O(1) space - where n is the length of the first input array and m is the length of the second input array
Write a function that takes in two non-empty arrays of integers, finds the pair of numbers (one from each array) whose absolute difference is closest to zero, and returns an array containing these two numbers, with the number
from the first array in the first position.
Note that the absolute difference of two integers is the distance between them on the real number line. For example, the absolute difference of -5 and 5 is 10, and the absolute difference of -5 and -4 is 1.
You can assume that there will only be one pair of numbers
with the smallest difference.
Sample Input:
arrayOne = [-1, 5, 10, 20, 28, 3]
arrayTwo = [26, 134, 135, 15, 17]
Sample Output:
[28, 26]
#interview
#interviewshorts #codinginterviewquestions #codinginterviews #quickinterviewprep #javascriptcoding #javascriptinterviewquestions #shorts
Practice it using the link in the bio! Go give it a go! 🚀
Question 6: Find the pair of numbers with smallest difference
Difficulty: Medium
Expected Optimal Space & Time Complexity:
O(nlog(n) + mlog(m)) time | O(1) space - where n is the length of the first input array and m is the length of the second input array
Write a function that takes in two non-empty arrays of integers, finds the pair of numbers (one from each array) whose absolute difference is closest to zero, and returns an array containing these two numbers, with the number
from the first array in the first position.
Note that the absolute difference of two integers is the distance between them on the real number line. For example, the absolute difference of -5 and 5 is 10, and the absolute difference of -5 and -4 is 1.
You can assume that there will only be one pair of numbers
with the smallest difference.
Sample Input:
arrayOne = [-1, 5, 10, 20, 28, 3]
arrayTwo = [26, 134, 135, 15, 17]
Sample Output:
[28, 26]
#interview
#interviewshorts #codinginterviewquestions #codinginterviews #quickinterviewprep #javascriptcoding #javascriptinterviewquestions #shorts
Among all pairs of numbers whose difference is 16, find a pair whose product is as small as possibl…...
Find the common factors of a given pair of numbers?
Pair Numbers 1 to 18 to form perfect square Find pair with 1
Finding Factor Pairs
Find by inspection the H.C.F pair of numbers #easy #
find by inspection,the LCM of each pair of the following numbers
Find Pair of Numbers Whose Geometric Mean is Whole Number
How to find common multiples of a given pair of numbers?
Algebra: Finding the Least Common Multiple (LCM) of the Pair of Numbers
Write Fraction Halfway Between each Pair
Find the pair of natural numbers whose LCM is 78 and HCF is 13
5. Find the pair of the greatest and the smallest rational numbers from amongst
Finding the Highest Common Factor (HCF) of a Pair of Numbers #shorts
Finding the Lowest Common Multiple (LCM) of a Pair of Numbers #shorts
How to find the pair of Integers when Sum & Difference is given?| Integers concepts
Harder Pigeonhole Principle Problems (Part 1: Pair of numbers which sum to 12)
'Which of the following is a pair of co-primes?(a) (16, 62) (b) (18, 25) (c) (21, 35) (d) (23, ...
Two Sum | Find a Pair in an Integer Array Whose Sum is Equal to a Target Number | JavaScript
How to Determine If an Ordered Pair is a Solution to a System of Equations
How to determine if an ordered pair is a function or not
Find the smallest pair of 4 digit numbers such that the difference between them is 303 and their HCF
Measurements Of Numbers/ Unit Conversion/ Dozen/ Gross/ Score/Pair/Century/#artikipathshala #shorts
Which of the following pair represents the same number ` -16/20 and 20/-25`
Which of the following is a pair of co-primes?
Комментарии