编码 面试_在学习编码面试时如何取得进步

编码 面试

by Sam Gavis-Hughson

萨姆·加维斯·休森(Sam Gavis-Hughson)

在学习编码面试时如何取得进步 (How to make progress while studying for coding interviews)

Getting stuck is never fun. Especially when you’re working really hard. And yet, I find that this happens to people preparing for coding interviews all the time.

卡住从来都不是一件好事。 尤其是当您非常努力的时候。 但是,我发现这种情况经常发生在准备编写采访访谈的人们身上。

You put in consistent work. You’ve gone through hundreds of practice problems and block out an hour every day to study. But you’re just not progressing.

您进行了一致的工作。 您已经遇到了数百个练习题,每天花一个小时学习。 但是你只是没有进步。

Even after all this prep work, you still feel like every problem is a new challenge that you don’t quite know how to solve. You can solve the problems most of the time, but it doesn’t feel like it’s getting that much easier.

即使完成了所有这些准备工作,您仍然会觉得每个问题都是一个新的挑战,您不太知道如何解决。 您大多数时候都可以解决问题,但是感觉并没有那么容易。

When I work with 1:1 coaching clients, this is exactly the situation that I often find them in. And in almost all of the cases, once we identify the thing (or things) holding them back, they experience major breakthroughs. Resolving these issues has gotten my clients jobs at Amazon, Bloomberg, Uber, and more!

当我与1:1的教练客户一起工作时,我经常会遇到这种情况。在几乎所有情况下,一旦我们发现阻碍他们前进的事物,他们就会取得重大突破。 解决这些问题使我的客户在亚马逊,彭博社,Uber等公司工作!

So what exactly is it that is holding you back? What is preventing you from making the progress you want? In this article, I will show you the ten most common problems that people struggle with. Fair warning, though: it can be really hard to identify these issues in yourself. If you really want to break through your issues, I recommend working with a coach.

那么到底是什么使您退缩呢? 是什么阻碍了您取得想要的进步? 在本文中,我将向您展示人们苦苦挣扎的十个最常见的问题。 不过要有合理的警告:要真正识别自己中的这些问题确实很困难。 如果您真的想解决问题,建议您与教练合作。

1.建立坚实的基础 (1. Develop a strong foundation)

I have talked about this issue before, but one of the most important keys to success in coding interviews is having a strong foundation of Computer Science fundamentals.

我之前已经讨论过这个问题 ,但是成功进行编码面试的最重要的关键之一就是要有坚实的计算机科学基础。

Over time, I’ve developed many different techniques to help my students improve their problem solving in their interviews, like the FAST Method. However, none of these techniques are valuable if you don’t have strong fundamentals under your belt.

随着时间的推移,我开发了许多不同的技术来帮助学生改善面试中的问题解决能力,例如FAST方法 。 但是,如果您没有坚实的基础,这些技术都不是有价值的。

For example, the FAST Method is designed to help students with dynamic programming. The first step of the FAST Method is to find an initial brute force recursive solution. This is something that you need to be able to do on your own for the FAST Method to be of any use to you. Even if you understand the methodology, it won’t help you if you don’t know how to get that initial solution.

例如,FAST方法旨在帮助学生进行动态编程。 FAST方法的第一步是找到初始的蛮力递归解决方案。 这是您需要自己完成的事情,FAST方法才能对您有用。 即使您了解方法论,但如果您不知道如何获得初始解决方案,它也不会对您有帮助。

If you have strong fundamentals, then recursion is something that shouldn’t be difficult for you. It is a topic that comes up frequently enough that you should be able to whip it out whenever you want.

如果您有很强的基础知识,那么递归对您来说应该并不困难。 这是一个经常出现的话题,您应该可以随时随地将其淘汰。

Such is the case with all other fundamental data structures and algorithms. If you don’t know how to implement a linked list, then it doesn’t matter how many tricks you learn for solving linked list problems.

所有其他基本数据结构和算法都属于这种情况。 如果您不知道如何实现链表,那么您将学到多少技巧来解决链表问题都没有关系。

If you are lacking a formal Computer Science background, or simply find that the recommended problem solving techniques for coding interviews aren’t really helping you, then your first step should be to dedicate yourself to learning all of the fundamental data structures and algorithms.

如果您缺乏正式的计算机科学背景,或者只是发现建议的面试编码问题解决技术并没有真正帮助您,那么第一步应该是致力于学习所有基本数据结构和算法。

The best way to do that is to take either the MIT (Python) or Princeton (Java) data structures and algorithms course. Buy the book, do the assignments, and take the exams. If you put in the work, you can easily complete the course in 3 months or less, and you will have a strong foundation to move forward.

最好的方法是参加MIT (Python)或Princeton (Java)数据结构和算法课程。 买书,做作业,然后参加考试。 如果您投入工作,则可以在3个月或更短的时间内轻松完成该课程,并且将有坚实的基础继续前进。

2.获得更多的编码经验 (2. Get more coding experience)

Have you ever tried to do something for the first time? When I was first learning how to play guitar, it would take me 30 seconds to get the fingering for a basic chord. In theory, I could play any song if I had enough time and had the chord charts in front of me, but it wouldn’t sound very good.

您是否曾经尝试过做某事? 当我第一次学习如何弹吉他时,要花30秒才能掌握基本的和弦。 从理论上讲,如果我有足够的时间在我面前摆出和弦图,那么我就可以播放任何歌曲,但这听起来不太好。

Sometimes I work with students who are in a similar position with their coding. They simply have not reached a level of proficiency yet where they can easily write up the code in their interview.

有时,我会与在编码方面处于相似位置的学生一起工作。 他们只是还没有达到一定的熟练程度,就可以在面试中轻松编写代码。

In theory, the coding component of the interview should be the easy part. As long as you’ve practiced on a whiteboard, the hard part of your interview should be developing a solution in the first place before you ever write a line of code. If this is not true, then you probably need to improve your coding skills.

从理论上讲,面试的编码部分应该很容易。 只要您在白板上进行练习,面试中最困难的部分就是应该在编写一行代码之前首先开发解决方案。 如果不是这样,那么您可能需要提高编码技能。

There are also some groups that are more affected by this issue than others. Primarily, those who have less experience coding. I often see bootcamp grads, Masters students who switched into Computer Science for their Masters from a different field, or long term managers who simply haven’t coded in a while struggling the most with coding.

还有一些群体比其他群体受此问题影响更大。 主要是那些编码经验较少的人。 我经常看到训练营的毕业生,从不同领域转向计算机科学专业的硕士生,或者长期未曾在编码方面苦苦挣扎的长期经理。

The key here is simply to get more practice coding, and ideally do so in an environment where you are getting good feedback on your code. One of the best ways to do this is by contributing to open source projects. Not only is this a great way to show off your experience, but you will get the benefit of thorough code reviews and learning how to work in a production environment.

此处的关键只是简单地获取更多的实践编码,并且理想情况下是在对代码获得良好反馈的环境中进行。 做到这一点的最好方法之一就是为开源项目做贡献。 这不仅是展示您的经验的好方法,而且您将受益于彻底的代码审查和学习如何在生产环境中工作。

If you’re new to working with open source, First Timers Only is a great resource for those looking to get started. They share tutorials on how to contribute, and have compiled a list of potential projects that would be good for beginners.

如果您不熟悉开放源代码,那么“ 初学者专用”对于那些希望入门的人来说是一个很好的资源。 他们分享了有关如何做出贡献的教程,并整理了一系列对初学者有益的潜在项目。

3.策略性地解决每个面试问题 (3. Strategically approach each interview question)

When going into battle, any general who expects to succeed has a detailed plan. If you want to succeed in your interview, you need to have a detailed plan as well.

参战时,任何希望成功的将军都有详细的计划。 如果要在面试中取得成功,还需要制定详细的计划。

The most common plan I see to solving interview problems looks something like the following:

我看到的解决面试问题的最常见计划如下所示:

  1. Look at the problem

    看问题
  2. Think about the problem

    考虑问题
  3. Come up with a solution

    提出解决方案
  4. Write the solution

    写解决方案
  5. Success

    成功

However, do you notice a problem here? Hopefully the first thing you asked was “How do I come up with a solution?” This plan totally lacks any sort of strategy for coming up with the solution. It assumes that the solution will just appear.

但是,您在这里注意到问题了吗? 希望您问的第一件事是“我如何提出解决方案?” 该计划完全缺乏提出解决方案的任何策略。 它假定解决方案将仅出现。

And that’s how most people think about interview problems. They memorize tons of solutions with the hope that one of them will be similar enough to the problem they’re faced with in their interview that a solution will magically materialize.

这就是大多数人对面试问题的看法。 他们记住了大量的解决方案,希望其中一个解决方案能够与他们在面试中所遇到的问题非常相似,即解决方案将神奇地实现。

This is risky at best.

这充其量是有风险的。

A far better way to interview is to have a clear game plan for how you’re going to approach each interview and each problem within the interview. Here is a rough outline of how you can approach an hour-long interview:

更好的面试方法是针对每个面试和面试中的每个问题制定清晰的游戏计划。 这是您如何进行一个小时的面试的粗略概述:

[0:00–0:05] Get settled and make sure that you fully understand the problem they’re asking. Work through any example inputs provided.

[0:00–0:05]安顿下来,并确保您完全了解他们所提出的问题。 完成提供的所有示例输入。

[0:05–0:10] Figure out a brute force solution to the problem. No coding at this point, just talk through it and draw any pictures if you find that helpful. If you’re stuck coming up with a brute force solution, try working through the problem by hand and translating your process for solving it into an algorithm.

[0:05–0:10]找出解决问题的蛮力解决方案 。 此时无需编码,如果发现有帮助,只需讨论一下并绘制任何图片。 如果您不愿提出蛮力解决方案,请尝试手动解决问题,并将解决问题的过程转化为算法。

[0:10–0:15] Optimize your solution. Take these 5 minutes to figure out the absolute best solution you can in this period of time. When comparing solutions, consider the time complexities.

[ 0:10–0:15]优化您的解决方案。 花这5分钟找出在这段时间内您可以使用的绝对最佳解决方案。 比较解决方案时,请考虑时间复杂度。

[0:15–0:35] Code up your solution. Even if it’s not optimal, it is better to have a complete, non-optimal solution than an incomplete, optimal solution.

[0:15–0:35]编写您的解决方案。 即使不是最佳方案,也要有一个完整的非最优方案,而不是一个不完整的最优方案。

[0:35–0:50] Test your code and fix any issues. This is incredibly important. It doesn’t matter if your code isn’t perfect the first time, but you had better be able to identify the errors.

[0:35–0:50]测试您的代码并解决所有问题。 这是非常重要的。 第一次代码是否不完美无关紧要,但是最好能够识别错误。

[0:50–1:00] Questions for your interviewer.

[0:50–1:00]给您的面试官的问题。

By following these steps, you achieve two things simultaneously. First, you budget your time effectively. The most frustrating thing in the world is running out of time when you totally know how to solve the problem.

通过执行以下步骤,您可以同时实现两件事。 首先,您可以有效地预算时间。 当您完全知道如何解决问题时,世界上最令人沮丧的事情就是时间用完了。

Second, these steps will help you ensure that you always get to a solution. By starting with the brute force solution and optimizing, you can almost guarantee that you will at least come up with some solution. Often times, the most optimal solution isn’t necessary if you do well in the rest of the interview.

其次,这些步骤将帮助您确保始终获得解决方案。 通过开始使用蛮力解决方案并进行优化,您几乎可以保证至少会提出一些解决方案。 通常,如果您在其余的采访中都做得不错,那么就不需要最佳解决方案。

4.考虑不同的可能解决方案 (4. Consider different possible solutions)

Did you know that most interview questions have more than one correct solution? I know, shocker, right? However, tons of people find a solution and then they just stop there without looking any further.

您是否知道大多数面试问题都有一个以上正确的解决方案? 我知道,令人震惊,对吧? 但是,成千上万的人找到了解决方案,然后他们就停在这里,不再寻找任何解决方案。

This always disappoints me. Often times, there is another solution that would have been even better and they were so close. Or maybe there were comparable solutions that had different tradeoffs.

这总是让我感到失望。 通常,还有另一种解决方案可能会更好,而且非常接近。 或者,也许有具有不同权衡的可比较解决方案。

For example, consider this problem:

例如,请考虑以下问题:

  • One solution has O(n) time complexity and O(1) space complexity

    一种解决方案具有O(n)时间复杂度和O(1)空间复杂度

  • Another solution has O(log n) time complexity and O(log n) space complexity

    另一种解决方案具有O(log n)时间复杂度和O(log n)空间复杂度

Which of these solutions is better?

这些解决方案中哪个更好?

Well that depends on what we are actually looking for. If we have a huge data set and not a lot of memory, the first solution might be better. However if memory is not an issue, then obviously we want to go with the second solution.

好吧,这取决于我们实际上正在寻找什么。 如果我们有一个庞大的数据集而没有很多内存,则第一个解决方案可能会更好。 但是,如果内存不是问题,那么显然我们想采用第二种解决方案。

The key here is that while in some cases there may be one “best” solution, there are way more problems where you can make different trade-offs and you have to decide which ones to make. As an interviewer, I love to see candidates who weigh the different possibilities.

这里的关键是,尽管在某些情况下可能有一个“最佳”解决方案,但是还有更多的问题需要您做出不同的权衡,而您必须决定要做出哪些选择。 作为一名面试官,我喜欢看到候选人在权衡各种可能性。

When you’re coming up with solutions, take a moment to think about other ways that you could solve the same problem. Could you make trade-offs that would improve the space usage in relation to time or vice versa?

当您提出解决方案时,请花点时间考虑可以解决同一问题的其他方法。 您能否权衡取舍,以改善与时间相关的空间使用率,反之亦然?

Finally, you should always consider the space and time complexity of every solution you come up with. This gives you an objective way to evaluate which solutions are better than others and helps make a way more informed decision about which solution to choose. If you have multiple solutions that are comparable, discuss with your interviewer and decide collaboratively which one would be the better approach.

最后,您应始终考虑所提出的每个解决方案的时空复杂性。 这为您提供了一种客观的方法来评估哪些解决方案比其他解决方案更好,并且有助于您在选择哪种解决方案时做出更明智的决定。 如果您有多个可比较的解决方案,请与面试官讨论并共同决定哪种方法更好。

5.从蛮力解决方案开始 (5. Start with the brute force solution)

I already mentioned this in passing in tip 3, but one of the biggest mistakes that people make when trying to solve interview problems is that they immediately try to find the most optimal solution to the problem.

我已经在技巧3中提到了这一点,但是人们在尝试解决面试问题时犯的最大错误之一就是他们立即尝试找到解决问题的最佳方法。

But let me ask you this: Which is better, a brute force solution or no solution?

但是,让我问您一个问题:哪种解决方案更好,还是蛮力解决方案?

I’ll tell you that finding a brute force solution is 1000% better than not finding a solution at all. And if you start by immediately trying to find the optimal solution, it is easy to get stuck and end up without a complete solution by the end of the interview.

我会告诉您,找到暴力解决方案比根本不解决方案要好1000%。 而且,如果您从立即尝试找到最佳解决方案开始,很容易陷入困境,最终在面试结束前就没有完整的解决方案。

While you don’t actually have to code it up, I recommend at least mentioning briefly how you could solve the problem with a brute force solution before you go on to try to optimize your solution. This accomplishes two important things:

虽然您实际上不必编写代码,但我建议至少简短地提及如何继续使用蛮力解决方案解决问题,然后再尝试优化解决方案。 这完成了两个重要的事情:

  1. It gives you a fallback plan. If you try to optimize your solution and fail, you can stop after 5 or 10 minutes and just code up your brute force solution. You might still pass the interview. Not all problems have optimal solutions.

    它为您提供了一个后备计划。 如果您尝试优化解决方案而失败,则可以在5或10分钟后停止并仅编写蛮力解决方案。 您可能仍会通过面试。 并非所有问题都有最佳解决方案。
  2. It helps you clarify the problem. Defining a brute force solution can help you to understand exactly what is involved in coming up with a solution to this problem. That is key. Understanding the problem in this deep way will make it easier to optimize.

    它可以帮助您澄清问题。 定义蛮力解决方案可以帮助您准确了解解决此问题的方案。 那是关键。 深入理解问题将使其更容易优化。

Attempting to immediately find an optimal solution may seem like the right approach because it will save valuable time. However, I find that the confusion that results from taking this approach often wastes a lot more time than you gain.

尝试立即找到最佳解决方案似乎是正确的方法,因为这样可以节省宝贵的时间。 但是,我发现采用这种方法所造成的混乱通常会浪费很多时间,而您所获得的时间却更多。

Starting with a brute force solution gives you clarity and a starting point to make everything else way easier.

从蛮力解决方案入手,可以让您更加清晰明了,并且可以从其他所有方面轻松实现。

6.在编写代码之前,请计划完整的解决方案 (6. Plan out the full solution before you code)

There are some super fancy whiteboards out there. But chances are, the whiteboard that you’re going to use is not going to have a copy-paste option. That means that you want to have a good outline of your code before you write it.

有一些超级花哨的白板在那里。 但是有可能,您将要使用的白板将没有复制粘贴选项。 这意味着在编写代码之前,您希望对代码有一个良好的概述。

Often times, people dive right into writing code as soon as they get asked a problem in their interview. Now it’s totally fine if you want to go ahead and define your method upfront, but that should be the extent of the code you write until you’ve fully worked out the solution. Writing any more code than that is a critical mistake for two reasons.

通常,人们在面试中被问到问题后便会立即着手编写代码。 现在,如果您想继续进行定义,就完全可以了,但这应该是您编写的代码的范围,直到您完全解决该问题为止。 编写两个以上的代码是一个严重错误,原因有两个。

First, as I said, whiteboards don’t have copy-paste functionality. That means that if you want to move lines of code around, you have to either erase and rewrite them or draw arrows going all over the place. You don’t really want your whiteboard to look like this:

首先,正如我所说,白板没有复制粘贴功能。 这意味着,如果要四处移动代码行,则必须擦除并重写它们,或者绘制遍历整个地方的箭头。 您真的不希望您的白板看起来像这样:

Keeping the whiteboard organized is easier for both you and your interviewer. It is easier for them to understand your solution and it’s much easier for you to keep track of what is going on. And if you decide to just rewrite stuff instead, you’ll be wasting a ton of valuable time.

对于您和您的面试官而言,使白板井井有条变得容易。 他们更容易理解您的解决方案,并且更容易掌握发生的情况。 而且,如果您决定改写内容,那将浪费大量宝贵的时间。

The other issue with starting to code right off the bat is that it can lock you into a specific way of thinking about the problem. We’ll talk about this more in point 7, but this can be incredibly harmful to your interview performance.

立即开始编写代码的另一个问题是,它可以使您陷入思考问题的特定方式。 我们将在第7点中进一步讨论此问题,但这可能会极大地影响您的面试表现。

Imagine that you see a problem and a solution immediately comes to mind. You start coding it up, but you realize that it is no longer optimal. You are unlikely to want to erase everything and start over. And even if you do, you’ll be locked into that mode of thinking.

想象一下,您发现一个问题并立即想到解决方案。 您开始对其进行编码,但是您意识到它不再是最佳的。 您不太可能希望擦除所有内容并重新开始。 即使这样做,您也将陷入这种思维方式。

There are problems where the optimal solution is completely unrelated to the brute force solution, and attempts to optimize the brute force solution will fail. If you wait to start coding, you avoid locking your mind into that one way of viewing the problem.

存在一些问题,其中最佳解决方案与蛮力解决方案完全无关,而优化蛮力解决方案的尝试将失败。 如果您等待开始编码,则可以避免将注意力集中在查看问题的一种方式上。

These concerns are why I always suggest that you fully understand the solution that you want to code up before you write the code. Draw pictures, write pseudo-code, do whatever you need to do to understand the solution. Once you start coding, it should be trivial because you already know exactly what to write.

这些问题就是为什么我总是建议您在编写代码之前完全了解要编写的解决方案。 绘制图片,编写伪代码,并做您需要做的一切以了解解决方案。 一旦开始编码,它应该是微不足道的,因为您已经确切知道要写什么。

7.牢记全局 (7. Keep the big picture in mind)

One of the biggest problems that I see for more experienced developers is that they get totally stuck in the weeds with a problem. They start obsessing over whether the loop should be <; N or &lt;= N and can’t figure out which is the right approach.

对于经验丰富的开发人员,我看到的最大问题之一是,他们完全陷入困境。 他们开始迷恋循环是否应该< ; N or & lt; = N,无法弄清楚哪种方法是正确的。

This is a perfect example of losing the forest for the trees. The question they’re trying to solve becomes one of “How do I write this loop correctly?” instead of “What purpose is this loop serving in the greater context of my code?”

这是失去森林以换取树木的完美例子。 他们试图解决的问题成为“如何正确编写此循环?”之一。 而不是“此循环在我的代码的更大上下文中起什么作用?”

A perfect example of this is a problem where you try to use the wrong data structure. Let’s say that you’re storing the values indexed from 1-N and you decide you want to use a HashMap. You can insert 1 -> value1, 2 -> value2, and so on.

尝试使用错误的数据结构的问题就是一个很好的例子。 假设您要存储从1-N索引的值,然后决定要使用HashMap。 您可以插入1 -> val 1, 2 ->值1,2- 1, 2 ->值2,依此类推。

But now when you want to iterate over them in order, it is going to be a pain because you have to get all the elements from the HashMap and sort them. However, if you took a step back and looked at what you’re actually trying to do, you just want to store the value at each index and iterate through them. An array would be a much easier data structure to use.

但是现在,当您想要按顺序遍历它们时,将很痛苦,因为您必须从HashMap中获取所有元素并对它们进行排序。 但是,如果您退后一步,然后查看您实际要执行的操作,则只想将值存储在每个索引中并对其进行遍历。 数组将是更易于使用的数据结构。

Now you may be thinking, “I would never do something stupid like that,” but trust me, it happens all the time. Your thought process is non-linear when you’re solving problems, so you may have thought you needed a HashMap because of some other line of thinking that you have since abandoned.

现在您可能会想:“我永远不会做那样的愚蠢的事情,”但是请相信我,它一直在发生。 解决问题时,您的思考过程是非线性的,因此您可能会认为自己需要HashMap,因为此后便放弃了其他思路。

This is why it is so critical to stop every so often, especially if you start doing something that seems challenging, and look back at the big picture of what you’re trying to do. Whenever you’re doing something that seems unnecessarily complicated, look at your end goal and see if you can simplify your approach.

这就是为什么如此频繁地停下来如此重要的原因,特别是如果您开始做一些似乎具有挑战性的事情,然后回顾一下您想做的事情的全局。 每当您执行似乎不必要的复杂操作时,请查看最终目标,看看是否可以简化方法。

8.使用抽象来发挥自己的优势 (8. Use abstraction to your advantage)

I love asking complicated interview problems. If a problem involves several different components, you as the interviewer get such great insights into how a candidate manages their thinking when there is so much to deal with all at once.

我喜欢问复杂的面试问题。 如果一个问题涉及几个不同的组成部分,作为面试官,您将获得巨大的洞察力,以了解候选人在一次要处理的事情太多时如何管理他们的思想。

The key to successfully solving these problems is to use abstraction. At its core, this means breaking out your code into smaller functions with more specific purposes.

成功解决这些问题的关键是使用抽象。 从本质上讲,这意味着将您的代码分解为具有特定用途的较小函数。

Consider a simple example. Let’s say that we wanted to print out a linked list in reverse order. After working through this problem we realize that there is an O(n) time and space solution to the problem using a stack (push each element onto the stack as we iterate over the list and then pop each item and print), but we can solve the problem in O(n) time and O(1) space by reversing the linked list.

考虑一个简单的例子。 假设我们想以相反的顺序打印出一个链表。 解决此问题后,我们意识到使用堆栈可以解决该问题的O(n)时空解决方案(当我们遍历列表然后弹出每个项目并进行打印时,将每个元素推到堆栈上),但是我们可以通过反转链表来解决O(n)时间和O(1)空间中的问题。

Now it would be easy enough to reverse the linked list in our code, but what if we had a function to do that for us? That would make our lives way easier. We just call the function on the linked list, iterate over everything in the list and print it, and then reverse the list again so that we return our input to the original state.

现在,在我们的代码中反转链接列表就很容易了,但是如果我们有一个函数可以为我们做到这一点呢? 那将使我们的生活更轻松。 我们只调用链表上的函数,遍历列表中的所有内容并打印,然后再次反转列表,以便我们将输入返回到原始状态。

With that logic, we can now isolate the process of reversing a linked list and think about how to do that effectively. While this problem is a very simple example, it is easy to see how this reduces the amount of complexity we have to think about at any given time.

有了这种逻辑,我们现在可以隔离反转链表的过程,并思考如何有效地做到这一点。 尽管此问题是一个非常简单的示例,但很容易看出这如何减少了我们在任何给定时间都必须考虑的复杂性。

With more complicated problems, I recommend you ask yourself the question “What function, if it existed, would make my life easier right now?” If there is a clear function or functions, write your code assuming those functions already exist. Then you can go back afterwards and implement those functions, now that the rest of your code already works.

对于更复杂的问题,我建议您问自己一个问题:“如果存在的功能是什么功能,现在会让我的生活更轻松?” 如果存在明确的一个或多个功能,则假定这些功能已经存在,则编写代码。 然后,您的其余代码已经可以使用了,那么您可以随后返回并实现这些功能。

This has several advantages:

这有几个优点:

  1. If you run out of time, you still have a basically working code. Abstraction allows you to focus on the overall structure without having to get bogged down in the minutiae. If you have extra time, you can worry about the minutiae, but even if you don’t, it’s clear to your interviewer that you know what’s up.

    如果时间用完了,您仍然可以使用基本的代码。 通过抽象,您可以专注于整体结构,而不必陷入细节上。 如果您有多余的时间,您可以担心细节问题,但是即使您不这样做,面试官也很清楚您知道发生了什么。
  2. Clarity of thinking and code. They say that a clear desk means a clear mind and the same is true with code. The better you organize your code and break it up into manageable components, the easier it is to think about.

    思维和代码清晰。 他们说,桌子整洁意味着头脑清晰,代码也是如此。 您组织代码的方式越好,并将其分解为可管理的组件,就越容易思考。

I find that the more involved the problem is, the more valuable it can be to break things up into manageable components.

我发现问题越复杂,将事情分解成可管理的组件就越有价值。

9.测试您的代码 (9. Test your code)

When we are doing something new, we tend to forget a lot of the things that we already know. We assume that the things that we already know don’t apply.

当我们做一些新的事情时,我们往往会忘记很多我们已经知道的事情。 我们假设我们已经知道的事情不适用。

Consider this example: I’ve been learning how to play guitar in my spare time. I was struggling to make progress, so I asked my teacher for help, and he suggested that I write down some goals about what I wanted to accomplish. “DUH”. I write about this sort of thing all the time, but I failed to make the connection between coding interview prep and guitar practice.

考虑以下示例:我一直在学习如何在业余时间弹吉他。 我一直在努力进步,所以我向老师寻求帮助,他建议我写下一些关于我要完成的目标。 “ DUH”。 我一直都在写这种东西 ,但是我没能将面试准备和吉他练习联系起来。

In the same way, I find that many students forget to apply the best practices they know from real-world coding to their interviews. They assume that coding interviews are totally different, so the things they’d do normally don’t apply.

同样,我发现许多学生忘记了将他们在现实世界编码中所了解的最佳实践应用到面试中。 他们认为编码面试完全不同,因此他们通常不会做的事情。

One of the things people forget all of the time is to test their interview solution. But would you ever commit code in the real world without testing it thoroughly first?

人们一直忘记的事情之一就是测试他们的面试解决方案。 但是,您是否会在没有先对其进行全面测试的情况下在现实世界中提交代码?

You test your code because you want to make sure that it’s correct and that it does what you think it should do. This is even more important in the stressful environment of an interview because you are more prone to make mistakes.

您测试您的代码是因为您想确保它是正确的并且可以按照您的预期去做。 这在面试压力很大的环境中尤为重要,因为您更容易犯错误。

The key with testing your solutions is to actually go through the code line by line, tracking the values of each variable, and effectively “running” the code. If you just read through the code at a high level, you can very easily miss smaller issues with your code. I recorded a video that demonstrates exactly how to walk through and test your code.

测试解决方案的关键是实际上逐行遍历代码,跟踪每个变量的值,并有效地“运行”代码。 如果您只是高级别地阅读了代码,则很容易错过代码中的小问题。 我录制了一段视频 ,演示了如何逐步进行和测试您的代码。

I find that many students stress out about having their code be perfect the first time, and while this is a good aspiration, it rarely happens. It almost never happens in the real world so why would you expect it to happen in the more stressful environment of the interview? However, if you test your code thoroughly, you can fix any bugs and still end up with an A+ solution.

我发现许多学生都在强调第一次使自己的代码完美无缺,尽管这是一个很好的愿望,但很少发生。 它在现实世界中几乎从未发生过,那么您为什么期望它在面试压力更大的环境中发生? 但是,如果您对代码进行了彻底的测试,则可以修复所有错误并最终获得A +解决方案。

10.获得良好的反馈 (10. Get good feedback)

Doing real-world interviews is a great way to get better at interviewing. You can get more comfortable with the experience and give yourself plenty of opportunities to succeed. An often-recommended strategy is to schedule a ton of interviews with the ones you’re least excited about first. That way you get to practice interviewing where you don’t really care about the outcome so that you’re more prepared when the important interviews come around.

进行真实世界的采访是一种更好地提高采访效率的好方法。 您可以更轻松地体验,并给自己提供很多成功的机会。 通常推荐的策略是安排对您最不感兴趣的采访进行大量的采访。 这样,您就可以练习面试,而您并不真正在意结果,因此,当重要面试到来时,您将为准备更加充分。

While I think this strategy has merits, there is one fatal flaw: Companies are notoriously bad at giving you any meaningful feedback.

虽然我认为这种策略是有好处的,但存在一个致命的缺陷:众所周知,公司在向您提供任何有意义的反馈方面表现很差。

“So,” you might say, “Who cares? I can just judge my own performance.”

“那么,”您可能会说,“谁在乎? 我可以判断自己的表现。”

Well yes, that’s true, but it can be really hard to judge yourself. You don’t know what criteria your interviewer is looking for (just getting an optimal solution to one problem may not cut it). And if you’re struggling to succeed, chances are there’s something that you’re not seeing.

是的,的确如此,但是很难判断自己。 您不知道您的面试官在寻找什么标准(仅针对一个问题获得最佳解决方案可能无法解决问题)。 而且,如果您为成功而奋斗,那么有可能您看不到某些东西。

This is why mock interviews, and on top of that ideally working with a coach, are so important. Mock interviews give you the opportunity to get detailed feedback on your performance. The interviewer can also tell you if there are things that you didn’t notice

这就是为什么模拟面试如此重要,而且在理想情况下还要与教练合作如此重要。 模拟面试使您有机会获得有关您表现的详细反馈。 面试官还可以告诉您是否有您没有注意到的事情

If you’re really serious about doing well in your interviews, I also recommend working with a coach on top of the mock interviews. Mock interviews are individual data points. They tell you that on a particular problem at a particular time, you did well or poorly. However a coach can look at all these data points and help you make connections. They can help you see the specific things you need to work on to improve different aspects of your interview performance.

如果您真的很想在面试中表现出色,我还建议您在模拟面试的基础上与教练合作。 模拟访谈是个人数据点。 他们告诉您,在特定时间的特定问题上,您的表现很好或很差。 但是,教练可以查看所有这些数据点并帮助您建立联系。 他们可以帮助您了解需要进行哪些特定工作以改善面试表现的各个方面。

Ultimately, mock interviews give you data points and coaches help you connect the dots. Getting this sort of feedback is the best possible way to accelerate your interview progress.

最终,模拟面试会为您提供数据点,而教练则可以帮助您联系各个方面。 获得此类反馈是加快面试进度的最佳方法。

Time and again, I see people stall out in their interviews. And it’s almost always for one of the reasons described above. If you’re not making the kind of progress that you want, read this article closely. Identify your problem area(s) and work to correct it. In time, you will be able to refine your interviewing and start getting the calls you want to hear.

我一次又一次看到人们在面试中陷入僵局。 而且几乎总是出于上述原因之一。 如果您没有取得所需的进展,请仔细阅读本文。 确定您的问题区域并进行纠正。 随着时间的流逝,您将能够完善面试并开始接听您想听到的电话。

翻译自: https://www.freecodecamp.org/news/how-to-make-progress-while-studying-for-coding-interviews-894c320bfa74/

编码 面试

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值