Skip to content

Determining minimum distance between 2 point in a 2D infinite grid.

Notifications You must be signed in to change notification settings

a1nouru/Min-Steps-in-Infinite-Grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Min-Steps-in-Infinite-Grid

Determining minimum distance between 2 point in a 2D infinite grid.

You are in an infinite 2D grid where you can move in any of the 8 directions :

(x,y) to 
(x+1, y), 
(x - 1, y), 
(x, y+1), 
(x, y-1), 
(x-1, y-1), 
(x+1,y+1), 
(x-1,y+1), 
(x+1,y-1) 
  • You are given a sequence of points and the order in which you need to cover the points. Give the minimum number of steps in which you can achieve it. You start from the first point.

For example : Input : [(0, 0), (1, 1), (1, 2)] Output : 2 steps

  • Explanation: It takes 1 step to move from (0, 0) to (1, 1). It takes one more step to move from (1, 1) to (1, 2).

Contributed by Nouru Muneza.

About

Determining minimum distance between 2 point in a 2D infinite grid.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages