Skip to content

Commit 567670e

Browse files
Sean PrashadSean Prashad
authored andcommitted
Add Tips component
1 parent 84eedd6 commit 567670e

File tree

7 files changed

+365
-21
lines changed

7 files changed

+365
-21
lines changed

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"react": "^16.12.0",
1717
"react-dom": "^16.12.0",
1818
"react-icons": "^3.8.0",
19+
"react-markdown": "^4.3.1",
1920
"react-scripts": "3.3.0",
2021
"react-scroll": "^1.7.15",
2122
"react-table": "^7.0.0-rc.15",

web/src/components/Table/styles.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.table {
2+
padding-top: 1rem;
3+
24
.row {
35
justify-content: center;
46
}

web/src/components/Tabs/index.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import {
1212
import classnames from 'classnames';
1313

1414
import Table from '../Table';
15+
import Tips from '../Tips';
16+
17+
import './styles.scss';
1518

1619
const Tabs = () => {
1720
const [activeTab, setActiveTab] = useState('1');
@@ -40,24 +43,28 @@ const Tabs = () => {
4043
toggle('2');
4144
}}
4245
>
43-
Moar Tabs
46+
Tips
4447
</NavLink>
4548
</NavItem>
4649
</Nav>
47-
<TabContent activeTab={activeTab}>
48-
<TabPane tabId="1">
49-
<Row>
50-
<Col>
51-
<Table />
52-
</Col>
53-
</Row>
54-
</TabPane>
55-
<TabPane tabId="2">
56-
<Row>
57-
<Col>Tab pane 2</Col>
58-
</Row>
59-
</TabPane>
60-
</TabContent>
50+
<Container>
51+
<TabContent activeTab={activeTab}>
52+
<TabPane tabId="1">
53+
<Row>
54+
<Col>
55+
<Table />
56+
</Col>
57+
</Row>
58+
</TabPane>
59+
<TabPane tabId="2">
60+
<Row>
61+
<Col>
62+
<Tips />
63+
</Col>
64+
</Row>
65+
</TabPane>
66+
</TabContent>
67+
</Container>
6168
</Container>
6269
);
6370
};

web/src/components/Tabs/styles.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.tab-pane {
2+
.active {
3+
display: flex !important;
4+
justify-content: center;
5+
}
6+
}

web/src/components/Tips/index.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react';
2+
import ReactMarkdown from 'react-markdown';
3+
4+
import './styles.scss';
5+
6+
const Tips = () => {
7+
const input = `
8+
\`\`\`md
9+
If input array is sorted then
10+
- Binary search
11+
- Two pointers
12+
13+
If asked for all permutations/subsets then
14+
- Backtracking
15+
16+
If given a tree then
17+
- DFS
18+
- BFS
19+
20+
If given a graph then
21+
- DFS
22+
- BFS
23+
24+
If given a linked list then
25+
- Two pointers
26+
27+
If recursion is banned then
28+
- Stack
29+
30+
If asked for maximum/minumum subarray/subset/options then
31+
- Dynamic programming
32+
33+
If asked for top/least K items then
34+
- Heap
35+
36+
If asked for common strings then
37+
- Map
38+
- Trie
39+
40+
Else
41+
- Map/Set for O(1) time & O(n) space
42+
- Sort input for O(nlogn) time and O(1) space
43+
\`\`\``;
44+
45+
return <ReactMarkdown className="tips" source={input} />;
46+
};
47+
48+
export default Tips;

web/src/components/Tips/styles.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.tips {
2+
text-align: center !important;
3+
4+
display: block;
5+
overflow-x: auto;
6+
padding: 0.5em;
7+
color: #333;
8+
background: #f8f8f8;
9+
}

0 commit comments

Comments
 (0)