Min Steps in Infinite Grid Solution Program [InterviewBit Question]

Minimum Steps in Infinite Grid.

This programming question is often asked in many It Giants Interview questions and competitive programming Questions. Often Google and Amazon asked in their Software Engineering interview.

The same programming question you can also find on the InterviewBit: Coding Interview Question.

In this post, we are going to solve the problem in Java. You can also solve the Minimum steps to reach the destination in your choice of programming language.

You might like this also: Find Duplicate In Array (Java)- InterviewBit Problem Solution

Problem Statement of Minimum Steps in Infinite Grid Competitive Programming Question

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),

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.

Example :

Input : [(0, 0), (1, 1), (1, 2)]
Output: 2

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).

How to Print Colored Text Console Output in Java

Java Source Code of Minimum Steps in Infinite Grid

You can also get more competition programming question solution on here.

You can also get latest coding problems and many more code snippets directly to your Email by subscribing our newsletters.

You Might Like This

Linked List Data Structure Program In Java

How to Create 2D Matrix Using ArrayList Collection Class In Java

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *