[Discuss] MATRIX TRAVERSAL

Hey folks,
Let’s discuss anything related to the MATRIX TRAVERSAL problem in this thread.

Sir I am submitting the answers for task 1 of matrix traversal.But my answers are not getting submitted and next task is still locked.

edge-test-1 Module 3 I have perform all necessary check of matrix bounds , plus starting positing check still , plus dir < 4 and dir > 0 still fails help ?

No test case for dir>4 and dir<0. they are the constraints.

Return -1 in list if its out of bound. Dont return valid moves until -1 just return -1 as the list

3 Likes

@gouravsardana
it should be clearly mentioned in overview

Seriously man! It was not at all clearly mentioned!

Sorry about that. We’ll make the correction.

my edge case 1 failing can someone suggest me some edge cases.

1 Like


Screenshot from 2020-03-12 22-22-23

I tried different test cases and my code was working correctly when tested on work-space but on submission I got a assessment failure.
Also the sample inputs passed on work-space but failed during assessment.
Any hints!

1 Like

C++ support was introduced yesterday and for folks who are already in the ME, a few additional steps are needed. Please await instruction on slack if you want to use C++.

1 Like

But I’ve successfully submitted previous modules in c++.

Please check the codeblitz channel on slack.

The matrix might be any combination of 2 D (i.e. it is not always square matrix). So make sure that your boundary condition for X and Y should be according to matrix length MxN. That is X < M and Y < N .

edge-test-1

Position Checked initial and during iteration
returned -1 if out of bound during the iteration
checked if empty matrix
direction valid checked
numberSteps checked

why is it failed?

1 Like

Does your code return a single -1 in the list/vector when you see out of bounds?
Try out such a case and see if -1 get printed out.

You mean:
-1
or
[-1]

[-1]. If you look at the stub, it has to return a list.

2 Likes

Hints section disappears when I try to unlock a hint and after a reload reappears with it being unlocked. Happened a couple of times already.

Shouldn’t the time complexity of this question is O(numberOfSteps)?
Which is not the case in debrief