This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Why we use line change outside the inner loops ? | |
Answer) We change the line for once only after executing both inner loops | |
because our inner loops work for the columns, and the outer loop works for the row. | |
_________________________________________________________________ | |
2) Why pattern is not printing properly in case of even input ? | |
Answer) We do not get the desired pattern for even values of 'n' because, for this pattern we increment our stars upto the mid row, | |
but in case of even input, we do not get a proper line for seperation. So, the pattern prints correctly initially, but after the first half | |
the pattern won't look as desired. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Suppose if we are given only the length of string, can you print the number of permutations ? | |
Answer) yes, number permutions are simply equal to the factorial of length of string, like, | |
if we have length of string as 4 then total number of permutations is going to be | |
4 * 3 * 2 * 1 = 24 | |
(think and maditate for more approaches) | |
_________________________________________________________________ | |
2) Can there be a non recursive approach ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
Another question that will help you get better understanding of arrays data structure, in this you have to find an element that is smallest in the respective row and largest in the column. Watch video for better understanding. | |
Question Name: | |
Saddle Price | |
Question Link : | |
https://www.pepcoding.com/resources/online-java-foundation/2d-arrays/saddle-price-official/ojquestion | |
Question Statement: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
he historic state of Wakanda has various monuments and souveniers which are visited by many travellers every day. The guides follow a prescribed route of visiting the monuments which improves them understand the relevance of each monument. The route of the monument is fixed and expressed in a 2-d matrix where the travellers visit the prescribed next monument. For example | |
1 2 3 | |
4 5 6 | |
7 8 9 | |
is the prescribed route and the visitors travels this path: 1->2->3->4->5->6->7->8->9 | |
However, a certain visitor decides to travel a different path as follows: | |
1. The visitor only plans to visit the upper diagonal triangle of the monument list. | |
2. The visitor travels diagonally till there are no more moves left in the current journey. | |
3. He then visits the adjacent monument to the first monument of current diagonal journey. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
This one is a rather important question, brief intro is provided in question statement, take that as reference, but, we suggest you to watch the video for better understanding of the problem | |
Question Name: | |
Ring Rotate | |
Question Link: | |
https://www.pepcoding.com/resources/online-java-foundation/2d-arrays/ring-rotate-official/ojquestion | |
Question Statement: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
In this problem we are required to rotate a matrix by 90 degrees, so for that we need to first transpose the matrix and then mirror it's row elements, basically swap its row elements like first with last and so on, watch the video for better understanding. | |
Question Name: | |
Rotate By 90 Degree | |
Question Link : | |
https://www.pepcoding.com/resources/online-java-foundation/2d-arrays/rotate-by-90-degree-official/ojquestion | |
Question Statement: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include<string> | |
using namespace std; | |
void printEncoding(string str, string asf){ | |
if(str.length() == 0) { // base case | |
cout << asf << endl; | |
return; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void printPermutations(string str, string asf){ | |
if(str.length() == 0) { // base case | |
cout << asf << endl; | |
return; | |
} | |
for(int i = 0; i < str.length(); i++) { // loop for traversing the string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
void printMazePathsWithJumps(int sr, int sc, int dr, int dc, string psf) { | |
if(sr == dr && sc == dc) { //base case | |
cout << psf << endl; | |
return; | |
} | |