Skip to content

Commit fa84edf

Browse files
committed
updated interview notes
1 parent a645dff commit fa84edf

File tree

4 files changed

+127
-2
lines changed

4 files changed

+127
-2
lines changed

docs/aws-study.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66

77
## Content
88

9+
* [CloudFormation](#cf)
910
* [RDS - MySQL](#rds)
1011
* [EC2](#ec2)
1112

1213

1314

15+
</br><a name="cf"></a>
16+
## AWS CloudFormation
17+
18+
* [Sceptre](https://github.com/Sceptre/sceptre) is a tool to drive
19+
[AWS CloudFormation](https://aws.amazon.com/cloudformation)
20+
21+
1422
</br><a name="rds"></a>
1523
## AWS RDS
1624

docs/interview.md

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@
178178
<a name="design-db"></a>
179179
### Database Design
180180

181+
#### Concepts
182+
181183
* ACID
182184
- **Atomicity**: Transactions are often composed of multiple statements. Atomicity guarantees that each transaction is treated as a single "unit", which either succeeds completely, or fails completely: if any of the statements constituting a transaction fails to complete, the entire transaction fails and the database is left unchanged. An atomic system must guarantee atomicity in each and every situation, including power failures, errors and crashes.
183185

@@ -187,10 +189,61 @@
187189

188190
- **Durability**: guarantees that once a transaction has been committed, it will remain committed even in the case of a system failure (e.g., power outage or crash). This usually means that completed transactions (or their effects) are recorded in non-volatile memory.
189191

192+
#### SQL Query
193+
194+
* For DB tables:
195+
196+
```sql
197+
-- containers(id, name);
198+
CREATE TABLE IF NOT EXISTS containers (
199+
`id` INT NOT NULL AUTO_INCREMENT COMMENT 'PK for containers',
200+
`name` VARCHAR(45) NULL COMMENT 'container name',
201+
PRIMARY KEY (`id`)
202+
);
203+
204+
-- items(id, type);
205+
CREATE TABLE IF NOT EXISTS items (
206+
`id` INT NOT NULL AUTO_INCREMENT COMMENT 'PK for items',
207+
`type` VARCHAR(45) NULL COMMENT 'Item type',
208+
PRIMARY KEY (`id`)
209+
);
210+
211+
-- containeritem(container_id, item_id);
212+
CREATE TABLE IF NOT EXISTS containeritem (
213+
`container_id` INT NOT NULL COMMENT 'Composite PK: FK to containers.id',
214+
`item_id` INT NOT NULL COMMENT 'Composite PK: FK to items.id',
215+
CONSTRAINT `FK__containeritem_container_id`
216+
FOREIGN KEY (`container_id`)
217+
REFERENCES `containers` (`id`),
218+
CONSTRAINT `FK__containeritem_item_id`
219+
FOREIGN KEY (`item_id`)
220+
REFERENCES `items` (`id`)
221+
);
222+
```
223+
Write a SQL query to list all container names, item types, and count of types (including zero) for each container.
224+
225+
```sql
226+
SELECT d.name, d.type,
227+
CASE WHEN ci.item_id IS NULL THEN 0 ELSE count(ci.item_id) END as 'count'
228+
FROM (
229+
SELECT c.id as 'c_id', c.name, i.id as 'i_id', i.type
230+
FROM containers c
231+
CROSS JOIN items i
232+
) d -- optionally to use CTE
233+
LEFT OUTER JOIN containeritem ci ON d.i_id = ci.item_id
234+
AND d.c_id = ci.container_id
235+
GROUP BY d.name, d.type
236+
ORDER BY d.name, d.type
237+
;
238+
```
239+
See http://sqlfiddle.com/#!9/20fa2b/52
240+
190241

191242
<a name="design-system"></a>
192243
### System Design
193244

245+
#### Checklist
246+
194247
* A.B.C.D.
195248
- **_A_**sk questions (what features? how much to scale? ...)
196249
- Don't use **_b_**uzzword
@@ -287,6 +340,31 @@
287340
* HAProxy
288341

289342

343+
#### Example: Find the peakest time
344+
345+
From a long list of trip time (with Start and End time, sorted by Started), e.g. within a whole month, find the peakest trip time.¶
346+
347+
```go
348+
type Trip struct {
349+
Start time
350+
End time
351+
}
352+
353+
// assuming the list (e.g. a whole month/year) is sorted by start time
354+
func countPeakTrips(a []Trip) int {
355+
356+
}
357+
```
358+
359+
360+
#### Example: Design a stock data system
361+
362+
* requirements
363+
- get real time price
364+
- get historic trend
365+
* data schema and database
366+
* misc consideration
367+
290368

291369
### Resources:
292370

@@ -575,7 +653,7 @@
575653

576654

577655
<br/><a name="non-tech"></a>
578-
### Non-technical
656+
## Non-technical
579657

580658
* [Psychological Tricks](https://github.com/yangshun/tech-interview-handbook/blob/master/non-technical/psychological-tricks.md)
581659
* [Questions to ask](https://github.com/yangshun/tech-interview-handbook/blob/master/non-technical/questions-to-ask.md)
@@ -584,7 +662,7 @@
584662

585663

586664
<br/><a name="reading"></a>
587-
### Reading
665+
## Reading
588666

589667
* Books/Collection:
590668
* [Computer Science in JavaScript](https://github.com/humanwhocodes/computer-science-in-javascript)

docs/karat.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
* [Karat Technical Categories](#categories)
99
* [Karat Coding Questions](#coding)
10+
* [Miscellaneous](#misc)
1011

1112

1213
<br /><a name="categories"></a>
@@ -42,6 +43,11 @@
4243
* Testing
4344
* What is race condition and how it happens?
4445

46+
* Others
47+
- Know Graph very well. Read a lot of graph problems from leet code and geek for geeks.
48+
49+
50+
4551

4652
<br /><a name="coding"></a>
4753
## Karat Coding
@@ -140,3 +146,19 @@
140146
ranges = getMostBookedRanges(workers)
141147
# expecting [(2, 3), (4, 6)]
142148
```
149+
150+
151+
<br /><a name="misc"></a>
152+
## Miscellaneous
153+
154+
* Open questions:
155+
- How would you explain Google to your grandmother?
156+
- How would you teach her to fix her Facebook if there was an error or malfunction?
157+
- What's something your building? What's an ecommerce company you use?
158+
159+
* Others
160+
- Given an array of fruits and an other array weights of fruits, write a function to pick the fruits randomly with a probability distribution equal to its weights.
161+
- Given a graph and a node in the graph, return a deep copy of the node.
162+
- Given a frequency distribution of objects, write a random object generator which produces objects based on their probability distribution.
163+
- Given a binary tree with parent pointers (pointers that direct from leaves to the root), design an O(1) space complexity algorithm to find the lowest common ancestor of any two nodes.
164+
- Evaluate an arithmetic expression that only involves multiplication and addition.

ml/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,20 @@
66
## Contents
77

88
* [Design API Server](./api/README.md)
9+
10+
11+
12+
<br/>
13+
14+
```
15+
-+++++= .+++++=
16+
.+@@@@@+ #@@@@*:
17+
.@@@@@= *@@@@@
18+
@+@@@@- =#@@@@@
19+
@ +@@@@: :% @@@@@
20+
@ *@@@@-%: @@@@@
21+
@ *@@@@- @@@@@
22+
-@- #@@+ :@@@@@:
23+
-#@@@#- ## =@@@@@@@=
24+
....... .........
25+
```

0 commit comments

Comments
 (0)