India’s Best Job Seekers and Training Platform Forums Java Problems set Suppose you are given a puzzle that is represented as a matrix…

  • Suppose you are given a puzzle that is represented as a matrix…

  • Akash 

    Administrator
    at

    Suppose you are given a puzzle that is represented as a matrix with 0s and 1s, where a 0 indicates you’re allowed to move into that position and 1 means you’re not allowed to move in that position. Write a function that given a start position and an end position, returns a boolean value indicating if there exists a path from start to end. you are only allowed to move up, left, right and down. Diagonal movement is not allowed.

    Example #1

    Input

    0 0 1 0 1

    0 0 0 0 0

    0 1 1 1 1

    0 1 1 0 0

    start: 4,1

    end 0,3

    Output – true

    Example #2

    Input

    0 0 1 1 1

    0 1 0 0 0

    1 1 1 1 1

    0 0 0 0 1

    start: 0,0

    end: 1,2

    Output – false

Log in to reply.

Original Post
0 of 0 posts June 2018
Now
KodNest Training New Batch is starting on 02nd November 2020. Attend one week free demo classes.Register Now

New Report

Close