Computers and Technology

You are given 2 arrays representing integer locations of stores and houses (each location in this problem is one-dementional). For each house, find the store closest to it. Return an integer array result where result[i] should denote the location of the store closest to the i-th house. If many stores are equidistant from a particular house, choose the store with the smallest numerical location. Note that there may be multiple stores and houses at the same location. Example 1:Input: houses = [5, 10, 17], stores = [1, 5, 20, 11, 16]Output: [5, 11, 16]Explanation: The closest store to the house at location 5 is the store at the same location. The closest store to the house at location 10 is the store at the location 11.The closest store to the house at location 17 is the store at the location 16.Example 2:Input: houses = [2, 4, 2], stores = [5, 1, 2, 3]Output: [2, 3, 2]Example 3:Input: houses = [4, 8, 1, 1], stores = [5, 3, 1, 2, 6]Output: [3, 6, 1, 1]

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 05:00, 420420blazee
Are special characters that allow you to search for multiple words at the same time.
Answers: 2
image
Computers and Technology, 23.06.2019 22:30, ghari112345
Jamie has to enter the names, employee id’s, and income of a group of employees into a worksheet. which option will jamie use to describe the data
Answers: 3
image
Computers and Technology, 24.06.2019 01:30, jadaroyval
Write a program that asks the user to enter the name of an input file. if the file does not exist, the program should prompt the user to enter the file name again. if the user types quit in any uppercase/lowercase combinations, then the program should exit without any further output.
Answers: 3
image
Computers and Technology, 24.06.2019 18:30, kristine2424
Is a type of bullying that takes place when a person intentionally posts negative information about another that is not true
Answers: 1
Do you know the correct answer?
You are given 2 arrays representing integer locations of stores and houses (each location in this pr...

Questions in other subjects: