Skip to content

Instantly share code, notes, and snippets.

@pradhuman7d1
Created October 22, 2021 06:27
Show Gist options
  • Save pradhuman7d1/a2f2bb62d97cdbecb8cf6ba578deadfb to your computer and use it in GitHub Desktop.
Save pradhuman7d1/a2f2bb62d97cdbecb8cf6ba578deadfb to your computer and use it in GitHub Desktop.
Exit Point of a Matrix
Description:
This problem is to improve your knowledge about basics of java and also to make you familiar with the data structure - Arrays.
In this problem we will start from the top left corner and traverse through the array with the constraint that whenever we encounter a cell containing a 1, we will take a 90° right turn, and will move straight while we encounter a 0.
Thats it about the problem, watch the video and have fun while learning...
Question Name:
Exit Point of a Matrix
Question Link:
https://www.pepcoding.com/resources/online-java-foundation/2d-arrays/exit-point-matrix-official/ojquestion
Question Statement:
1. You are given a number n, representing the number of rows.
2. You are given a number m, representing the number of columns.
3. You are given n*m numbers (1's and 0's), representing elements of 2d array a.
4. Consider this array a maze and a player enters from top-left corner in east direction.
5. The player moves in the same direction as long as he meets '0'. On seeing a 1, he takes a 90 deg right turn.
6. You are required to print the indices in (row, col) format of the point from where you exit the matrix.
Topic: #Basics_of_Java #Functions_and_Arrays #2D_Arrays
Used #DataStructure: #Array #2dArray
#TimeComplexity: O(m*n)
#SpaceComplexity: O(1)
--------------------------------------------------------------
Dependent Questions:
1. 2d Arrays Demo :
a. Pepcoding Portal Link: https://www.pepcoding.com/resources/online-java-foundation/2d-arrays/2d-arrays-demo-official/ojquestion
--------------------------------------------------------------More Youtube PlayList:
Level 1 In Java English : https://www.youtube.com/playlist?list=PL-Jc9J83PIiHxc8vuYMq3C1KUvqc_jB6L
Level 1 In Java Hindi : https://www.youtube.com/playlist?list=PL-Jc9J83PIiFj7YSPl2ulcpwy-mwj1SSk
Level 2 In Java Hindi : https://www.youtube.com/playlist?list=PL-Jc9J83PIiE-181crLG1xSIWhTGKFiMY
Constructive Algorithm - Level 3 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiGRNj_KILSAuhvAHS4_4Y5N
Geometry - Level 3 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiH0l9IZvdeC55dbFQpdMDSS
Maths for CP - Level 3 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiFs8E0EGeckM89cD8E6sFro
DP - Level 3 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiG1ebya3hpf65MgYYyDkK4W
Euler Tour - Level 3 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiHymm1DHZBkac0_hhFBXryO
Ternary Search : https://www.youtube.com/playlist?list=PL-Jc9J83PIiGiFr2WFAiS9nEssqEoCKC4
Recursion & Backtracking - Level 1 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiFxaBahjslhBD1LiJAV7nKs
Recursion & Backtracking - Level 2 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiHO9SQ6lxGuDsZNt2mkHEn0
Graphs - Level 1 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiHfqDcLZMcO9SsUDY4S3a-v
Dyanmic Programming - Level 1 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiG8fE6rj9F5a6uyQ5WPdqKy
Generic Trees - Level 1 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiEmjuIVDrwR9h5i9TT2CEU_
Time and Space - Level 1 : https://www.youtube.com/playlist?list=PL-Jc9J83PIiFc7hJ5eeCb579PS8p-en4f
---------------------------------------------------------------
Pepcoding has taken the initiative to provide counselling and learning resources to all curious, skillful and dedicated Indian coders. This video is part of the series to impart industry-level web development and programming skills in the community.
We also provide professional courses with live classes and placement opportunities.
For more visit our website: https://bit.ly/2ZCS68a
For more free study resources, visit: https://bit.ly/3liICaJ
Have a look at our result: https://bit.ly/2YcmDZR
Follow us on our Youtube page: https://www.youtube.com/c/Pepcoding/featured
Follow us on our FB page: https://www.facebook.com/pepcoding
Follow us on Instagram: https://www.instagram.com/pepcoding
Follow us on LinkedIn: https://www.linkedin.com/company/pepcoding-education
Follow us on Pinterest: https://in.pinterest.com/Pepcoding/_created/
Follow us on Twitter: https://twitter.com/pepcoding
.
.
.
Happy Programming !!! Pep it up
----------------------------------------------------------------
#Arrays #2dArrays #IntroductiontoDataStructures #TraversingArrays
=================================================================
Tags:
coding, pepcoding, pep, programming, softwareDevelopment, Internship, SDE Questions, NADOS, JAVA, CPP, java language, java in english, pepcoding in english, java in english, arrays, basic data structures, learn DSA, pepcoder, sumeet sir, rajneesh sir, jeetu sir, jasbir sir, jitender sir, subesh sir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment