subject

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]

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:30
Ted wants to go out to a neighborhood park and shoot pictures of dew drops on grass. he wants to get a low-level angle of the dew drops. which support equipment should ted use? a. mini tripod b. pistol grip c. monopod d. body mount
Answers: 2
question
Computers and Technology, 22.06.2019 13:00
Why the bear has a slunky tail determine the meaning of the word slunk in the story
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
What is a costume plot? why is it important to a film or theater production?
Answers: 2
question
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
You know the right answer?
You are given 2 arrays representing integer locations of stores and houses (each location in this pr...
Questions
Questions on the website: 13722362