{ Cracking The Coding Interview: 150 programming Q&A } 5th edition Part II
来源:互联网 发布:香港最新直播软件 编辑:程序博客网 时间:2024/06/07 03:59
Chap 6 Technical questions
How to practice a question:
1. solve by myself
2. write code on paper
3. test on paper
4. type to computer and record bugs
Handling technical questions:
1. ask questions to resolve ambiguity
data types, data amout, assumptions, user?
2. design an algorithm
time and space complexity, what happens if lots of data, cause other issues, with limitations how to make trade-offs, with specific data have you leveraged the information?
First give brute force solution, then optimize it.
3. pseudocode
first write false codes, and then tell interviewers that you will start writing real codes.
4. code
write codes at a nice, slow, methodical pace.
Use data structures generously: show that you have concern about this basic fondations.
Don't crowd your coding: start from left-upper and leave enough space to write other codes.
5. test
extreme cases, user error, general cases.
When finding bugs, first think about why and then correct it.
Five algorithm approaches:
1. Examplify
Write out specific examples of the problem and see if you can derive a general rule from there.
E.g Find the angle between hour and minute hands.
The angle between the minute hand and 12 o'clock: 360 * m / 60
The angle between the hour hand and 12 o'clock: 360 * ( h % 12 ) / 12 + 360 * ( m / 60 ) / 12
So : (hour angle - minute angle) % 360 = (30 * h - 5.5 * m ) % 360
2. Pattern matching
Consider what problems the algorithm is similar to and try to modify the existing solution to solve the problem.
E.g A sorted array has been rotated such as 4567123, how you find the minium element? Assume all elements are unique.
1. Find the minimum element. --- Not useful, it doesn't use the information.
2. Binary search --- If MID < RIGHT then the minimun element must be less then MID.
3. Simplify and generalize
First, we change a contraint such as the data type or amount of data.
Then, we solve this new simplified problem.
Finally, we try to generalize the earlier solution for more complex version.
4. Base case and build
We first solve the problem for base case (e.g. n = 1) and then for n = 2, 3... assuming we have the solutions for previous cases. Likerecursive.
5. Data structure brainstorm
Simply run through a list of data structures and try to apply each one.
E.g numbers are randomly generated and stored in an array, how to keep track of the median?
LinkedList? not good at accessing and storing data.
Array? already have.
Binary tree? binary search tree, but the root cannot be 2 elements.
Heap? use 2 heaps to separate bigger half and smaller half. Good solution!
What good coding looks like?
Correct, efficient, simple, readable, maintainable.
Tips:
1. use data structures more generally
2. appropriate code reuse
3. modular
4. flexible and robust
5. error checking
Chap 7 The offer and beyond
Evaluating the offer
1. financial package
signing bonus, relocation, and other time perks.
cost of living difference.
annual bonus.
stock options and grants.
2. career development
3. company stability
4. the happiness factor
the product, manager and teammates, company culture, hours.
5. negotiation if necessary
On the job:
1. set a timeline for your career path
2. build strong relationships
3. ask for what you want
- { Cracking The Coding Interview: 150 programming Q&A } 5th edition Part II
- { Cracking The Coding Interview: 150 programming Q&A } 5th edition Part I
- { Cracking The Coding Interview: 150 programming Q&A } --- Arrays and Strings
- Cracking the Coding Interview
- 《Cracking the coding interview》
- Cracking The Coding Interview
- Cracking the coding interview
- Cracking the coding interview
- cracking the coding interview 4th-笔记-Tips
- Cracking the coding interview--Q2.5
- Cracking the Coding Interview Chap1 Q1.5
- Cracking the coding interview--Q1.5
- Cracking the coding interview--Q1.5
- Cracking the coding interview--Q2.5
- Cracking the coding interview--Q3.5
- Cracking the coding interview--Q4.5
- Cracking the coding interview--Q5.5
- Cracking the coding interview--Q8.5
- Python常见错误汇总
- html5的地图及画布
- dubbo-admin-2.5.4在tomcat中部署失败的问题
- hive技术总结
- Qt: 给Widget设置背景图片
- { Cracking The Coding Interview: 150 programming Q&A } 5th edition Part II
- 原码, 反码, 补码 详解
- STM32学习第一天---安装好了CooCox debuger了解了点GPIO
- 我阅读过的C/C++开源项目---有的经过有的路过有的啃过有的改过
- QWidget的背景颜色和背景图片的设置
- nodejs
- 腾讯 体育 VIP 账号共享 仅限一个月
- leetcode之Remove Nth Node From End of List
- Qt之对话框设计——利用QPalette改变控件颜色