Skip to content

编码面试备忘单:事前、事中和事后的最佳实践

原文:https://www.techinterviewhandbook.org/coding-interview-cheatsheet/

随着多年来编码面试的成熟,现在对候选人在编码面试中应该如何表现有了更坚定的期望。其中一些做法也有助于你通过展示你良好沟通和处理障碍的能力,向面试官展示“录用”信号。

从顶级候选人那里获得最佳实践,并基于在编码面试中你将如何被评估,我们在一份详尽的清单中总结了一些在编码面试中如何表现的顶级技巧——包括要避免的顶级错误。

甚至在你开始练习你的编码面试问题之前,你应该阅读并熟悉这个指南。伴随着这个指南的 LeetCode grinding 将会让你在早期就牢牢记住这些重要的编码面试行为。

做什么之前你的编码面试T3】

  • Dress Comfortably.

    Usually you don't need to wear beautiful clothes, just relax. T-shirts and jeans are acceptable in most places.

  • ✅确保你已经阅读并准备好你的自我介绍要问的最后问题

对于虚拟现场编码面试

Summary of what to do before a virtual onsite coding interview

What to do before a virtual onsite coding interview

  • Prepare pen and paper.

    In case you need to record and imagine something. It is especially helpful for drawing trees/figures

  • Use earphones or headphones and make sure you are in a quiet environment.

    Avoid using speakers, because if the echo is loud, communication will be difficult, and repetition by participants will only lead to the loss of valuable time.

  • ✅检查一下你的网络连接是否正常。

  • ✅检查你的网络摄像头和音频工作正常。
  • Familiarize and set up shortcuts in the coding environment (code rpad/code pen).

    Set the shortcut keys of the editor, turn on auto-completion, tab spacing, etc. If you know shortcuts and make good use of them, the interviewer will be impressed with you

  • Turn off the web cam if possible.

    Most remote interviews don't need video chat, and having video chat on will only distract attention and take up network bandwidth.

进行电话屏幕编码面试

Summary of what to do before a phone screen coding interview

What to do before a phone screen coding interview

  • Use earphones and put the phone on the table.

    Avoid holding the phone with one hand and typing with the other hand

  • ✅请求使用 Zoom/Google Meet/Hangouts 或 Skype 代替电话。

    更容易发送链接或文本. .

    T3】

对于现场白板编码面试

  • Learn about whiteboard space management.

    Leave space between lines of code in case you need to insert lines between existing codes.

在你的编码面试 期间做什么

Summary of what to do during a coding interview

What to do during a coding interview*

1.在面试开始时做好自我介绍

  • *Introduce yourself in a few sentences under a minute or 2.

    How to introduce yourself for software engineers according to our guide * ✅ Sound enthusiastic!

    Smile and talk, and you will naturally sound more attractive. * ❌,不要在自我介绍上花太多时间,因为你剩下的编码时间会更少。*

2.收到问题后,进行澄清

不要马上开始编码。编码问题往往含糊不清、不够具体,目的是让面试官衡量求职者对细节和细心的关注程度。至少问 2-3 个澄清性问题。

  • *✅复述并重复面试官的问题。

    确保你完全明白他们在问什么. .

    T3】 * ✅阐明假设(参考算法备忘单了解常见假设)

    • The tree graph is probably a graph that allows circulation, and a simple recursive solution won't work. Clarify whether a given diagram is a tree or a graph.

    • Can you modify the original array/graph/data structure in any way?

    • How is the input stored?

    • If you were given a word dictionary, would it be a list of strings or a Trie?

    • Is the input array sorted? (for example, for deciding between binary/linear searches)*

    • *✅阐明输入值范围。

    投入:多大,范围是什么?

    T3】 * Clarify input value format

    values: negative? Floating point? Empty? Null? Repeat? Oversized? * Work through a simplified example to assure you under the question.

    For example, you are asked to write a palindrome checker, and before coding, come up with simple test cases, such as "kayak" = > true, "mouse" = > false, and then check with the interviewer whether these examples meet their expectations * ❌不要马上开始编程,或者在面试官给你开绿灯之前就开始。*

3.与面试官一起制定并优化你的方法

接下来你能做的最糟糕的事情就是直接跳到编码——面试官希望有一些时间来进行双向讨论,讨论解决问题的正确方法,包括对时间和空间复杂性的分析。

根据问题的复杂程度,讨论时间从几分钟到 5-10 分钟不等。这也给面试官一个机会给你提示,引导你找到一个可以接受的解决方案。

  • ✅:如果你在方法或优化上卡住了,用这种结构化的方法来唤起你的记忆/找到一个好的方法
  • *✅ Explain a few approaches that you could take at a high level (don't go too much into implementation details) . discuss the trade offers of each approach with your interviewer as if the interviewer was your coworker and you are all collaborating on a problem.

    For algorithm problems, space/time is a common trade-off. Let's take the famous 2 and problems as examples. There are two common solutions-(1) using nested for loops. This is O (n 2 ) in terms of time complexity and O(1) in terms of space. (2) In one pass of the array, you can hash a value to the index in the hash table. For subsequent values, look up the hash table to see if you can find an existing value that can be added to the target value. This method is O(N) in time and space. Discuss these two solutions, propose a compromise, and summarize which solution is better (usually the one with lower time complexity) * And explain the time and space complexity of your proposed approach (es).

    Mention the great complexity of time and explain the reasons (for example, O (n 2 means time because there are nested for loops; O(n) for space, because an extra array is created). Use algorithm optimization technology to master all the time and space complexity. * ✅同意最理想的方法,并对其进行优化。识别重复/重复/重叠的计算,并通过缓存减少它们。请参阅第页优化您的解决方案 * ❌不要马上开始编程,或者在面试官给你开绿灯之前就开始。 * ❌不会忽视任何一条给定的信息。 * ❌似乎对你的方法和分析没有把握。*

4.一边讨论一边写出你的解决方案

  • ✅:只有在你解释了你的方法并且面试官给你开了绿灯之后,你才可以开始编程。
  • *✅解释你在编码/写作时试图达到的目标。比较相关的不同编码方法。

    这样做,证明你掌握了你选择的编程语言. .

    T3】 * Code/write at a rational speed so you can talk through it-but not too slow.

    You want to type slowly enough to explain the code, but not too slow, because you may not have time to answer all the questions * ✅写实际的可编译的工作代码,而不是伪代码。 * Write clean, straight forward and neat code with as few syntax errors/bugs as possible.

    Always choose a clean and simple implementation instead of a complicated and chaotic one. Ensure that neat coding style and good coding practice are adopted according to language examples and structures. Grammatical errors and bugs should be avoided as much as possible. * Use variable names that explain your code.

    Good variable names are important because you need to explain your code to the interviewer. It is best to use a long variable name that can explain the problem. Suppose you need to find multiples of 3 in a set of numbers. Name the result as array multiplesOfThree instead of array/number. * ✅请求允许使用琐碎函数,而不必实现它们。

    例如reducefilterminmax应该都可以使用 * Write in a modular fashion, going from higher-level functions and breaking them down into smaller helper functions.

    Suppose you are asked to make a car. You can just write a few advanced functions: gatherMaterials(), assemble(). Then decompose assemble() into smaller functions, makeEngine(), polishWheels(), constructCarFrame(). You can even ask the interviewer if you can not write some trivial helper functions. * ✅ If you are cutting corners in your code, State that out loud to your interviewer and say what you would do in a non-interview setting (no time constraints).

    For example, "In a non-interview setting, I will write a regular expression to parse this string instead of using split() which may not cover some marginal situations." * ✅ 【现场/白板】练习白板空间管理 * ❌:当你的面试官在说话的时候,不要打断他们。通常,如果他们说话,他们是在试图给你暗示或引导你到正确的方向。 * ❌不花太多时间写评论。 * ❌不要重复自己 * ❌不使用不好的变量名。

    • 不要使用极其冗长或单字符的变量名,(除非它们很常见,如in)变量名*
    • ❌不会在没有检查的情况下复制和粘贴代码(例如,一些变量在粘贴后可能需要重命名)。

5.编码后,检查你的代码并添加测试用例

一旦你完成了编码,不要宣布你完成了。面试官希望你开始扫描错误并添加测试用例来改进你的代码。

  • *Scan through your code for mistakes-such as off-by-one errors.

    Read through your code with a pair of fresh eyes-just like the first time you saw a piece of code written by someone else-and discuss the process of finding your mistakes * Brain edge cases with the interviewer and add additional test cases. (refer to algorithms cheat cases for common corner cases)

    The given test cases are usually designed simply. Brainstorm possible edge situations, such as large size input, empty set, single item set, negative number. * ✅用那些测试用例一步一步地检查你的代码。 * ✅寻找可以重构的地方。 * Reiterate the time and space complexity of your code.

    This allows you to remind yourself of problems in your code that may deviate from the original time and space complexity. * ✅解释了权衡,以及如果给更多的时间,代码/方法可以如何改进。 * ❌不要马上宣布你完成了编码。先做到以上! * ❌不与面试官争论。他们可能是错的,但这是不太可能的,因为他们对这个问题很熟悉。*

6.面试结束时,留下好印象

  • *✅会问一些针对公司的好的最后问题。

    阅读提示和要问的示例最终问题. .

    T5】 * ✅感谢面试官 * ❌不会不问任何问题就结束面试。*

后做什么你的编码面试T3】**

Summary of what to do after a coding interview

What to do after a coding interview*

  • ✅把面试的问题和答案记录下来,因为这些对将来参考有用。
  • *✅给你的面试官发一封跟进邮件或 Linkedin 邀请,感谢他们抽出时间给你面试的机会。

    我自己作为一个面试官,这些都能给我留下持久的印象. .

    T3】*


我们一直在努力

apachecn/AiLearning

【布客】中文翻译组