Skip to content

Instantly share code, notes, and snippets.

@pradhuman7d1
pradhuman7d1 / code.cpp
Last active October 21, 2021 10:13
pepcoding.com 21/10/2021 printSubsequence
#include <iostream>
using namespace std;
void printSS(string ques, string ans) {
if(ques.length() == 0) { // base case
cout << ans << endl; // printing ans string
return;
}
printSS(ques.substr(1), ans + ques[0]); //recursive call including first character in ans string
@pradhuman7d1
pradhuman7d1 / code.cpp
Last active October 21, 2021 10:14
pepcoding.com 21/10/2021 printKPC
#include <iostream>
using namespace std;
string codes[] = {".;", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tu", "vwx", "yz"};
void printKPC(string ques, string asf){
if(ques.length() == 0) { //base case
cout << asf << endl;
return;
}
@pradhuman7d1
pradhuman7d1 / code.cpp
Last active October 21, 2021 10:15
pepcoding.com 21/10/2021 printStairPaths
#include <iostream>
using namespace std;
void printStairPaths(int n, string psf){
if(n == 0) { //base case
cout << psf << endl; //print output string psf(path so far)
return;
}
for(int jumps = 1; jumps <= 3; jumps++) { // loop for making all possible jumps
@pradhuman7d1
pradhuman7d1 / code.cpp
Last active October 21, 2021 10:17
pepcoding.com 21/10/2021 printMazePaths
#include <iostream>
using namespace std;
void printMazePaths(int sr, int sc, int dr, int dc, string psf){
if(sr == dr && sc == dc) { // base case
cout << psf << endl; // output
return;
}
if(sr > dr || sc > dc) { // to prevent illegal moves
@pradhuman7d1
pradhuman7d1 / code.cpp
Created October 21, 2021 10:07
pepcoding.com 21/10/2021 printMazePathsWithJumps
#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;
}
@pradhuman7d1
pradhuman7d1 / code.cpp
Last active October 21, 2021 10:18
pepcoding.com 21/10/2021 printPermutations
#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
@pradhuman7d1
pradhuman7d1 / code.cpp
Created October 21, 2021 10:12
pepcoding.com 21/10/2021 printEncodings
#include <iostream>
#include<string>
using namespace std;
void printEncoding(string str, string asf){
if(str.length() == 0) { // base case
cout << asf << endl;
return;
}
@pradhuman7d1
pradhuman7d1 / Exit Point of a Matrix
Created October 22, 2021 06:27
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
@pradhuman7d1
pradhuman7d1 / Rotate By 90 Degree
Created October 22, 2021 06:28
Rotate By 90 Degree
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:
@pradhuman7d1
pradhuman7d1 / Ring Rotate
Created October 22, 2021 06:29
Ring Rotate
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: