g*****x 发帖数: 799 | 1 以前曾经去过一次西雅图,过几天又要去了
感觉面试的时候设计题是我的软肋,答的时候总是磕磕绊绊的
想跟大家一起来讨论一下
以下列出一些我自己遇到过的或者在网上见过的题
欢迎大家讨论,补充
1. DB design of sys that enable paid customers to park, customers can either
book online beforehead or park at empty positions that are not booked
table Lot(id(pk), position, occupied);
table Customer(id(pk), name, phone);
table Lot_Customer(lid(pk), cid, start_time(pk), end_time);
2. OOD deck of cards
class Card {
enum Suits suit;
int value;
// getters & setters(check if suit & value are valid)
};
class Deck{
list cards;
Deck();
void shuffle();
Card front();
};
3. DB design of fridge inventory, can store products of different kinds,
different amounts and measurements/units (1 gallon milk, 2 dozen eggs),
expiration date (面试官不断加要求,搞得乱七八糟)
table Inventory(pid, exp_date, quantity, measurement)
table Product(pid, name)
table Type(tid, name, related_tid, relationship) // e.g. A-brand reduced fat
milk is Milk, B-brand full fat milk is also Milk, C-brand strawberry yogurt
is Yogurt, D-brand peach yogurt is also Yogurt, Milk and Yogurt are both
subtype of Dairy
table ProdType(tid, pid) // n to n relationship, each product can fall in
many types
table Measurement(pid, valid_measurement) // e.g. milk can be measured by "
gallon", "box", but not "bag"
4. OOD of a zoo, different types of animals (carnivores/herbivores,
hierarchical inheritance), cages (cage type, cage size, number of each type
of animal can be in the same cage), some of them cannot be put in the same
cage, need predator and prey relationships, what if, for instance, lion eat
1million different animals? i told him i can just put Herbivores in the prey
list of lion. he then asked what if mouse is herbivore, and lions don't eat
mice? (此题也是不断加要求,搞得相当乱)
5. OOD of elevator (道听途说,不知道原题有哪些要求)
class Elevator {
int curr_floor;
int capacity; // check if it's over-weight
int direction; // up, down, stop
list stop_floors;
void addStop(); // when button is pressed inside elevator
bool isStop(); // check if the elevator should stop at current floor
according to elevator algorithm
bool isOverweight();
void stopElev(); // open and close door, check weight, delete stop from
stop_floors list
};
class ElevGroup {
vector elevators;
list stop_floors;
void addStop(); // when button is pressed outside elevator
void schedule(); // pick an elevator and call elev.stopElev()
}; | g**e 发帖数: 6127 | 2 mark一下
还有著名的design chess game
either
fat
yogurt
type
eat
prey
eat
【在 g*****x 的大作中提到】 : 以前曾经去过一次西雅图,过几天又要去了 : 感觉面试的时候设计题是我的软肋,答的时候总是磕磕绊绊的 : 想跟大家一起来讨论一下 : 以下列出一些我自己遇到过的或者在网上见过的题 : 欢迎大家讨论,补充 : 1. DB design of sys that enable paid customers to park, customers can either : book online beforehead or park at empty positions that are not booked : table Lot(id(pk), position, occupied); : table Customer(id(pk), name, phone); : table Lot_Customer(lid(pk), cid, start_time(pk), end_time);
| g*****x 发帖数: 799 | 3 是国际象棋么?
【在 g**e 的大作中提到】 : mark一下 : 还有著名的design chess game : : either : fat : yogurt : type : eat : prey : eat
| s******n 发帖数: 65 | 4 我觉得设计题重要的是思路和考虑问题的全面,和面试官一边扯一边写最好, | x*****l 发帖数: 148 | 5 mark
以前曾经去过一次西雅图,过几天又要去了
感觉面试的时候设计题是我的软肋,答的时候总是磕磕绊绊的
想跟大家一起来讨论一下
以下列出一些我自己遇到过的或者在网上见过的题
欢迎大家讨论,补充
1. DB design of sys that enable paid customers to park, customers can either
book online beforehead or park at empty positions that are not booked
table Lot(id(pk), position, occupied);
table Customer(id(pk), name, phone);
table Lot_Customer(lid(pk), cid, start_time(pk), end_time);
2. OOD deck of cards
class Card {
enum Suits suit;
int value;
// getters & setters(check if suit & value are valid)
};
class Deck{
list cards;
Deck();
void shuffle();
Card front();
};
3. DB design of fridge inventory, can store products of different kinds,
different amounts and measurements/units (1 gallon milk, 2 dozen eggs),
expiration date (面试官不断加要求,搞得乱七八糟)
table Inventory(pid, exp_date, quantity, measurement)
table Product(pid, name)
table Type(tid, name, related_tid, relationship) // e.g. A-brand reduced fat
milk is Milk, B-brand full fat milk is also Milk, C-brand strawberry yogurt
is Yogurt, D-brand peach yogurt is also Yogurt, Milk and Yogurt are both
subtype of Dairy
table ProdType(tid, pid) // n to n relationship, each product can fall in
many types
table Measurement(pid, valid_measurement) // e.g. milk can be measured by "
gallon", "box", but not "bag"
4. OOD of a zoo, different types of animals (carnivores/herbivores,
hierarchical inheritance), cages (cage type, cage size, number of each type
of animal can be in the same cage), some of them cannot be put in the same
cage, need predator and prey relationships, what if, for instance, lion eat
1million different animals? i told him i can just put Herbivores in the prey
list of lion. he then asked what if mouse is herbivore, and lions don't eat
mice? (此题也是不断加要求,搞得相当乱)
5. OOD of elevator (道听途说,不知道原题有哪些要求)
class Elevator {
int curr_floor;
int capacity; // check if it's over-weight
int direction; // up, down, stop
list stop_floors;
void addStop(); // when button is pressed inside elevator
bool isStop(); // check if the elevator should stop at current floor
according to elevator algorithm
bool isOverweight();
void stopElev(); // open and close door, check weight, delete stop from
stop_floors list
};
class ElevGroup {
vector elevators;
list stop_floors;
void addStop(); // when button is pressed outside elevator
void schedule(); // pick an elevator and call elev.stopElev()
};
【在 g*****x 的大作中提到】 : 以前曾经去过一次西雅图,过几天又要去了 : 感觉面试的时候设计题是我的软肋,答的时候总是磕磕绊绊的 : 想跟大家一起来讨论一下 : 以下列出一些我自己遇到过的或者在网上见过的题 : 欢迎大家讨论,补充 : 1. DB design of sys that enable paid customers to park, customers can either : book online beforehead or park at empty positions that are not booked : table Lot(id(pk), position, occupied); : table Customer(id(pk), name, phone); : table Lot_Customer(lid(pk), cid, start_time(pk), end_time);
| f******n 发帖数: 264 | | l********n 发帖数: 684 | 7 Mark.
either
【在 g*****x 的大作中提到】 : 以前曾经去过一次西雅图,过几天又要去了 : 感觉面试的时候设计题是我的软肋,答的时候总是磕磕绊绊的 : 想跟大家一起来讨论一下 : 以下列出一些我自己遇到过的或者在网上见过的题 : 欢迎大家讨论,补充 : 1. DB design of sys that enable paid customers to park, customers can either : book online beforehead or park at empty positions that are not booked : table Lot(id(pk), position, occupied); : table Customer(id(pk), name, phone); : table Lot_Customer(lid(pk), cid, start_time(pk), end_time);
| b***e 发帖数: 15201 | 8 A公司还问过
design一个类似linux文件系统的文件系统,要能完成添加删除列表等基本功能 | d***e 发帖数: 793 | 9 For the 1st one, I think for reservation and occupancy, you need 2 separate
tables. Otherwise you need bit field to control the type in your
Lot_Customer table. Occupied field is not necessary in Lot table.
table Reservation(lid, cid, start_time, end_time);
table Occupancy(lid, cid, start_time, end_time);
either
【在 g*****x 的大作中提到】 : 以前曾经去过一次西雅图,过几天又要去了 : 感觉面试的时候设计题是我的软肋,答的时候总是磕磕绊绊的 : 想跟大家一起来讨论一下 : 以下列出一些我自己遇到过的或者在网上见过的题 : 欢迎大家讨论,补充 : 1. DB design of sys that enable paid customers to park, customers can either : book online beforehead or park at empty positions that are not booked : table Lot(id(pk), position, occupied); : table Customer(id(pk), name, phone); : table Lot_Customer(lid(pk), cid, start_time(pk), end_time);
| g*****x 发帖数: 799 | 10 not sure about that, actually, i don't remember the question clearly. but if
he meant non-registered customers can come and park at arbitrary not booked
position and leave whenever they want, so i thought an occupied field would
be enough
separate
【在 d***e 的大作中提到】 : For the 1st one, I think for reservation and occupancy, you need 2 separate : tables. Otherwise you need bit field to control the type in your : Lot_Customer table. Occupied field is not necessary in Lot table. : table Reservation(lid, cid, start_time, end_time); : table Occupancy(lid, cid, start_time, end_time); : : either
| | | d***e 发帖数: 793 | 11 in that case how do you handle double booking? you might book for morning,
I might book for afternoon.:)
but if
booked
would
【在 g*****x 的大作中提到】 : not sure about that, actually, i don't remember the question clearly. but if : he meant non-registered customers can come and park at arbitrary not booked : position and leave whenever they want, so i thought an occupied field would : be enough : : separate
| j*******a 发帖数: 61 | 12 mark
either
【在 g*****x 的大作中提到】 : 以前曾经去过一次西雅图,过几天又要去了 : 感觉面试的时候设计题是我的软肋,答的时候总是磕磕绊绊的 : 想跟大家一起来讨论一下 : 以下列出一些我自己遇到过的或者在网上见过的题 : 欢迎大家讨论,补充 : 1. DB design of sys that enable paid customers to park, customers can either : book online beforehead or park at empty positions that are not booked : table Lot(id(pk), position, occupied); : table Customer(id(pk), name, phone); : table Lot_Customer(lid(pk), cid, start_time(pk), end_time);
| g*****x 发帖数: 799 | 13 just insert in Lot_Customer if that lot is not booked for the time slot
【在 d***e 的大作中提到】 : in that case how do you handle double booking? you might book for morning, : I might book for afternoon.:) : : but if : booked : would
| t**r 发帖数: 3428 | | h**********8 发帖数: 267 | | c****l 发帖数: 1280 | | d**********g 发帖数: 1713 | 17 mark
either
【在 g*****x 的大作中提到】 : 以前曾经去过一次西雅图,过几天又要去了 : 感觉面试的时候设计题是我的软肋,答的时候总是磕磕绊绊的 : 想跟大家一起来讨论一下 : 以下列出一些我自己遇到过的或者在网上见过的题 : 欢迎大家讨论,补充 : 1. DB design of sys that enable paid customers to park, customers can either : book online beforehead or park at empty positions that are not booked : table Lot(id(pk), position, occupied); : table Customer(id(pk), name, phone); : table Lot_Customer(lid(pk), cid, start_time(pk), end_time);
| z*********a 发帖数: 320 | | g*******a 发帖数: 149 | | w****x 发帖数: 136 | 20 Agree. Each transaction is very flexible and could be M:M.
For any client faced system, you need to list a transaction as an
independent table first, and then consider M:M.
separate
【在 d***e 的大作中提到】 : For the 1st one, I think for reservation and occupancy, you need 2 separate : tables. Otherwise you need bit field to control the type in your : Lot_Customer table. Occupied field is not necessary in Lot table. : table Reservation(lid, cid, start_time, end_time); : table Occupancy(lid, cid, start_time, end_time); : : either
| | | e******3 发帖数: 11 | | n********p 发帖数: 708 | | r*******g 发帖数: 1335 | | j*****w 发帖数: 22 | 24 Amazon jobs:
http://myguiding.com/viewforum.php?f=97
either
【在 g*****x 的大作中提到】 : 以前曾经去过一次西雅图,过几天又要去了 : 感觉面试的时候设计题是我的软肋,答的时候总是磕磕绊绊的 : 想跟大家一起来讨论一下 : 以下列出一些我自己遇到过的或者在网上见过的题 : 欢迎大家讨论,补充 : 1. DB design of sys that enable paid customers to park, customers can either : book online beforehead or park at empty positions that are not booked : table Lot(id(pk), position, occupied); : table Customer(id(pk), name, phone); : table Lot_Customer(lid(pk), cid, start_time(pk), end_time);
| h******n 发帖数: 68 | | u***q 发帖数: 21 | |
|