Cracking the Coding Interview

會解題很重要

會解題很重要

會解題很重要

因為很重要所以要說三次

大部分想去美國念書的人,我想大部分都像我一樣想要在美國找工作對吧!但是該如何準備,說實在我沒有太多頭緒。

大部分的前輩都會建議把程式練好,線上題庫刷熟練一點,僅此而已。

我很困惑,難道我們東方社會那種追求解題的病態思維也感染到美國去了嗎?

我們好不容易脫離考試解題的升學制度,到了職場面試找實習又要開始新一輪追求解題速度和正確率嗎?

在一次偶然下,我知道一本關於面試的書籍Cracking the Coding Interview。這本書似乎給了我比較正確的解答,它帶我了解真正的面試究竟是怎麼一回事。

然而,實際的情況是…

對華人來說,英文不是母語,軟實力很難發揮(但是你還是要盡量發揮)。

缺少強力的軟實力,展現硬實力懂得解題才有談下去空間。

幫華人QQ

QQ完了後,還是要來面對現實,嗚嗚……

以下是Cracking the Coding Interview的作者拍的影片,作者會先介紹面試前可以準備的事,再來介紹程式的解題策略。

強烈建議看過!

Part1 - How Companies Evaluate Technical Interviews

第一部的重點只有一個,寫程式的時候把你的想法說出來!

別小看這個習慣,它可以無形中幫助你身邊的人了解你當下的思路。這可以協助面試官與你一同解程式時,了解你是不是在朝正確的方向思考。如果這時候你什麼地方卡住了,面試官也好協助你。這個過程,面試官除了知道我們程式的實力之外,也會想知道我們是不是有辦法順利和他們共事。

Part2 - How to Approach Behavioral Questions

第二部是教我們如何回答關於自己的履歷順帶引起聊天話題。

通常和面試官的開始的話題都是從我們的履歷開始,這個英文稱為 Resume Walk-Through,我們要透過履歷的話題成功讓面試官對你感興趣。我摘要出影片裡的一些建議,由於影片是英文加上實際運用的狀況也是用英文,摘要我就直接打成英文囉!

  • Give quick shows of success chronologically
  • Give key story to drive interviewer to ask more
  • Have some technical hobbies to share about (eg. write hexo blog, take online courses, code in hackrank)
  • Prepare 2 to 3 projects’ detail
    • Technical stuff (eg. what tools, what concepts)
    • Soft skill (eg. how you communicate, discuss w/ or persuade your coworkers)
    • Be proud of your failure! (if you are asked to say it. careful! you shouldn’t take too much time on this.)

Part3 - 7 Steps to Solve Algorithm Problems

第三部則是開始講解題囉!演算法解題7大步驟

  1. Listen
    • Typically every detail is needed to solve problem. if you solve it w/o every detail, you might not solve it OPTIMALLY
  2. Example
    • Usually your input examples are big and not special cases
  3. Brute Force
    • Better have it than nothing because it could
      • checks that you understandy the problem
      • shows you know this way
      • be a good place to optimize it

DO NOT CODE IT RIGHT NOW
You should state brute force and its run time, then optimize it!
4. Optimize
* There are many way to do so. It is better through discussion.
5. Walk through your Algorithm
* Know what you are going to do before coding
* what variables and data structures
* how, when and why do they change
* what is the structure of your code
6. Start Coding
* White Board:
* write straight
* use space wisely
* erase what you don’t need
* okay to use arrow
* write in top-left corner
* White Board and Computer
* Code Style Matters
* consistent braces
* consistent variable naming
* consistent spaces
* Modularize (before not after)
1. void doSomething(a, b){
int t = processingAlgo(a);
int s = processingAlgo(b);
}
2. int processingAlgo(k){… return intVariable}
7. Test
* Analysis
* think about each line
* double check things that looks weird or risky (decreasing for loop, math, etc.)
* Use test cases
1. small test cases first (can be applied on white board coding)
* fast to run
* get more test result
2. edge cases
3. big cases
* Remember
1. Think as you test, not as a bot.
2. Test the code, not Algorithm.
3. Think before you fix the bugs. Don’t panic!

Part4 - 3 Algorithm Strategies

第四部影片在講優化演算法的思路。每種演算法優化的方式有相當大的差異,雖然這裡提出的方法很基礎,可是它們都是相當常見而且容易引導我們想出解法的手段喔!

  1. B.U.D. (useful tools: hash table, break)
    • Bottlenecks
    • Unnessary works
    • Duplicated works
  2. Space / Time Tradeoffs
    • Always have HASH TABLE in mind
  3. D.I.Y. (Do it yourself aka. manually solving)
    • Think about if it is you not computer. How will you solve it?
    • Use a big example that is reasonably generic will help you.
    • Walk through brute force -> Hash table -> use a large and generic example.

以上就是一些解題思路。Cracking the Coding Interview這本書真的不錯建議去看看。
沒時間看書的朋友也看看影片吧!相信大家一定受益匪淺。
在真正的面試前,我們可以多用Hackrank和LeetCode練練感覺。
讓我們一起打拼吧!繼續衝刺解題囉!GO!