cracking the coding interview 4th-笔记-Tips

Five Steps to a Technical Questions

A technical interview question can be solved utilizing a five step approach:

  1. 1  Ask your interviewer questions to resolve ambiguity

  2. 2  Design an Algorithm

  3. 3  Write pseudo-code  first, but make sure to tell your interviewer that you’re writing pseudo-code! Otherwise, he/she may think that you’re never planning to write “real”code, and many interviewers will hold that against you

  4. 4  Write your code, not too slow and not too fast

  5. 5  Test your code and carefully x any mistakes

Step 1: Ask Questions 

to see if you ask good questions 

Good questions might be things like: What are the data types? How much data is there?What assumptions do you need to solve the problem? Who is the user? 


Step 2: Design an Algorithm 

While you’re designing your algorithm, don’t forget to think about

»  What are the space and time complexities?

»  What happens if there is a lot of data?

»  Does your design cause other issues? (i e , if you’re creating a modi ed version of a bi-nary search tree, did your design impact the time for insert /  find / delete?)

»  If there are other issues, did you make the right trade-o s?

»  If they gave you specific data (e g , mentioned that the data is ages, or in sorted order),have you leveraged that information? There’s probably a reason that you’re given it 



Step 3: Pseudo-Code 

  1. tell your interviewer that you’re writing pseudo-code first and that you’ll follow it up with “real” code 

» Use Data Structures Generously:  if you’re asked a problem involving  finding the minimum age for a group of people, consider defining a data structure to represent a Person This shows your interviewer that you care about good object oriented design 


» Don’t Crowd Your Coding:  When you’re writ-ing code on a whiteboard, start in the upper left hand corner – not in the middle This will give you plenty of space to write your answer 



Step 5: Test 


Consider testing for:

  • »  Extreme cases: 0, negative, null, maximums, etc

  • »  User error: What happens if the user passes in null or a negative value?

  • »  General cases: Test the normal case 


  1. testing while you’re writing the code rather than just at the end:complicated or highly numerical (bit shifting, arithmetic, etc) 


  1. carefully think through why the bug is occuring 

  1. For example, imagine a candidate writes a function that returns a number When he tests his code with the number ‘5’ he notices that it returns 0 when it should be returning 1 


Five Algorithm Approaches 


APPROACH I: EXAMPLIFY 

Description: Write out specific examples of the problem, and see if you can figure out a general rule 


APPROACH II: PATTERN MATCHING 

Description: Consider what problems the algorithm is similar to, and figure out if you can modify the solution to develop an algorithm for this problem 


APPROACH IV: BASE CASE AND BUILD 

Description: Solve the algorithm rst for a base case (e g , just one element) 


APPROACH V: DATA STRUCTURE BRAINSTORM 

Description: This is hacky, but it often works Simply run through a list of data structures and try to apply each one 


the more problems you do, the better instinct you will develop about which data structure to apply 


What about your career options? 

  • »  Career Path: Make a plan for your career What do you want to do 5, 10 and 15 years out? What skills will you need to develop? Which company or position will help you get there?

  • »  Promotion Opportunity: Do you prefer to move into management, or would you prefer to become an increasingly senior developer?

  • »  Money and Benefits: Of course, the money matters (but if you’re early in your career, it probably doesn’t matter much) As mentioned above, make sure you look at the full package 

  • »  Happiness: Did you like the people? The products? The location? It’s hard to tell, of course,before you work there What are the options to change teams if you’re unhappy?

  • »  Brand Name: The company’s brand name can mean a lot for your future career Some company names will open doors, while others will not as much 

  1. Before starting at a company, make a career plan What would you like your career to look like? What will it take to get there? Make sure you check in on your career plan regularly and are on track 


Top Ten Mistakes Candidates Make 

#1 | Practicing on a Computer 

Put away the compiler and get out the old pen and paper Use a compiler only to verify your solutions 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值