Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails for 50% of use cases #1

Open
mrishab opened this issue May 6, 2019 · 1 comment
Open

Fails for 50% of use cases #1

mrishab opened this issue May 6, 2019 · 1 comment

Comments

@mrishab
Copy link

mrishab commented May 6, 2019

Try the following input lot

lot = [
    [1,0,9,1],
    [1,0,1,1],
    [1,0,1,1],
    [1,0,1,1],
    [1,0,1,1],
    [1,0,1,1],
    [1,1,1,1],
]

Correct Answer: 15
Algorithm's Ouptut: 2

@hansrajdas
Copy link
Owner

Thanks Rishab for reporting this issue. Yes, you are right this is not the correct approach, we have to take care of the assumption that robot can only go on flat areas(that is on 1s) not on trenches(represented by 0).
I think, using DP with memoization will solve this problem.

Unfortunately, i will have to have remove this code snippet as i got a notice from DMCA.

Sorry for responding so late.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants