FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Problem-Solving/InterviewBit/PRETTY_PRINT.cpp at master · youssefAli11997/Problem-Solving · GitHub
youssefAli11997
/
Problem-Solving
Public
Notifications
You must be signed in to change notification settings
Fork
6
Star
3
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Problem-Solving
/
InterviewBit
/
PRETTY_PRINT.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (35 loc) · 805 Bytes
Breadcrumbs
Problem-Solving
/
InterviewBit
/
PRETTY_PRINT.cpp
Copy path
File metadata and controls
38 lines (35 loc) · 805 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
problem link : https://www.interviewbit.com/problems/prettyprint/
/*
imput :
5
output :
5 5 5 5 5 5 5 5 5
5 4 4 4 4 4 4 4 5
5 4 3 3 3 3 3 4 5
5 4 3 2 2 2 3 4 5
5 4 3 2 1 2 3 4 5
5 4 3 2 2 2 3 4 5
5 4 3 3 3 3 3 4 5
5 4 4 4 4 4 4 4 5
5 5 5 5 5 5 5 5 5
*/
vector<vector<
int
> > res;
void
recur
(
int
a,
int
b,
int
e){
if
(b > e)
return
;
for
(
int
i = b; i<=e; i++){
res[b][i] = a;
res[i][b] = a;
res[e][i] = a;
res[i][e] = a;
}
recur
(a-
1
, b+
1
,
e-1
);
}
vector<vector<
int
> >
Solution::prettyPrint
(
int
A) {
res.
clear
();
for
(
int
i=
0
; i<
2
*A-
1
; i++){
res.
push_back
(vector<
int
>());
for
(
int
j=
0
; j<
2
*A-
1
; j++)
res[i].
push_back
(
0
);
}
recur
(A,
0
,
2
*A-
2
);
return
res;
}
Back
|
FazBrowse Home
|
New Git URL