Skip to main content
added 64 characters in body
Source Link
user9207
user9207

For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y.

Examples:

X = (1 5,9) Y = (3,4,7) 

The distance is 2 + 1 + 2.

X = (1,2,3) Y = (0,8) 

The distance is 1 + 2 + 3.

Your code can take input in any way that is convenient.

The main restriction is that your code must run in linear time in the sum of the length of the two arrays.. (You can assume that adding two integers takes constant time.)

For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y.

Examples:

X = (1 5,9) Y = (3,4,7) 

The distance is 2 + 1 + 2.

X = (1,2,3) Y = (0,8) 

The distance is 1 + 2 + 3.

Your code can take input in any way that is convenient.

The main restriction is that your code must run in linear time in the sum of the length of the two arrays.

For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y.

Examples:

X = (1 5,9) Y = (3,4,7) 

The distance is 2 + 1 + 2.

X = (1,2,3) Y = (0,8) 

The distance is 1 + 2 + 3.

Your code can take input in any way that is convenient.

The main restriction is that your code must run in linear time in the sum of the length of the two arrays.. (You can assume that adding two integers takes constant time.)

Tweeted twitter.com/StackCodeGolf/status/1013524397821480961
Bolded the restriction
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 697

For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y.

Examples:

X = (1 5,9) Y = (3,4,7) 

The distance is 2 + 1 + 2.

X = (1,2,3) Y = (0,8) 

The distance is 1 + 2 + 3.

Your code can take input in any way that is convenient.

The main restriction is that your code must run in linear time in the sum of the length of the two arrays.your code must run in linear time in the sum of the length of the two arrays.

For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y.

Examples:

X = (1 5,9) Y = (3,4,7) 

The distance is 2 + 1 + 2.

X = (1,2,3) Y = (0,8) 

The distance is 1 + 2 + 3.

Your code can take input in any way that is convenient.

The main restriction is that your code must run in linear time in the sum of the length of the two arrays.

For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y.

Examples:

X = (1 5,9) Y = (3,4,7) 

The distance is 2 + 1 + 2.

X = (1,2,3) Y = (0,8) 

The distance is 1 + 2 + 3.

Your code can take input in any way that is convenient.

The main restriction is that your code must run in linear time in the sum of the length of the two arrays.

added 4 characters in body
Source Link
user9207
user9207

For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y.

Examples:

X = (1 5,9) Y = (3,4,7) 

The distance is 2 + 1 + 2.

X = (1,2,3) Y = (0,8) 

The distance is 1+2+31 + 2 + 3.

Your code can take input in any way that is convenient.

The main restriction is that your code must run in linear time in the sum of the length of the two arrays.

For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y.

Examples:

X = (1 5,9) Y = (3,4,7) 

The distance is 2 + 1 + 2.

X = (1,2,3) Y = (0,8) 

The distance is 1+2+3.

Your code can take input in any way that is convenient.

The main restriction is that your code must run in linear time in the sum of the length of the two arrays.

For this task your code should take two sorted arrays of integers X and Y as input. It should compute the sum of the absolute distances between each integer in X and its closest number in Y.

Examples:

X = (1 5,9) Y = (3,4,7) 

The distance is 2 + 1 + 2.

X = (1,2,3) Y = (0,8) 

The distance is 1 + 2 + 3.

Your code can take input in any way that is convenient.

The main restriction is that your code must run in linear time in the sum of the length of the two arrays.

Source Link
user9207
user9207
Loading