java面试步骤
If you’re anything like me, technical interviews can be very nerve recking, especially timed ones! You look at the problem, look at the ticking clock, and before you even read the question your palms are sweating and you’ve magically forgotten everything.
如果您像我一样,技术面试可能会非常令人讨厌,尤其是定时面试! 您看问题,看时钟,在甚至未读问题之前,您的手掌就出汗了,并且您已经神奇地忘记了一切。
Well, I’m here to help calm your nerves and, hopefully, help you get your thoughts in order so that you can pass that technical interview and be that much closer to getting your dream job.
好吧,我在这里是为了帮助您放松紧张,并希望可以帮助您使自己的想法井井有条,以便您可以通过技术面试,从而更接近获得理想的工作。
I was fortunate enough to dig into the world famous book ‘Cracking The Coding Interview’ by Gayle Laakmann McDowell. If you are a software engineer or just getting into the tech industry, I highly recommend you get your hands on a copy. The book does a great job of preparing individuals for the technical portion of the interview process. Today I am going to be talking about the seven steps to problem solving during a technical interview, discussed in the book.
我很幸运地深入研究了Gayle Laakmann McDowell撰写的世界著名著作《 Cracking The Coding Interview》。 如果您是软件工程师或刚进入技术行业,我强烈建议您拿一份副本。 这本书在为个人准备面试过程的技术部分方面做得很好。 今天,我将在书中讨论的技术面试中讨论解决问题的七个步骤。
步骤1:聆听 (Step 1: Listen)
You want to make sure you get a good grasp of the problem description. Be sure to ask any necessary question to clarify any details that may seem not so clear. Do not be afraid to ask questions! I find it helpful to take little notes and jot down specified details that the interviewer may have given so that I can refer back to the notes and be sure that my code takes all details into account.
您想确保对问题描述有很好的了解。 请务必提出任何必要的问题,以澄清似乎不太清楚的所有细节。 不要害怕问问题! 我发现记下一些笔记并记下面试官可能给出的特定细节很有帮助,这样我就可以参考这些笔记,并确保我的代码将所有细节都考虑在内。
步骤2:范例 (Step 2: Example)
Before you begin coding, you want to make an example case. Actually, you want to have multiple test cases for examples. But you don’t want to have an example that is too easy, because this may not cover all test cases and could easy slip past a specific detail. So what does a good example consist of? Well, according to ‘Cracking the Coding Interview’, your example should be: ‘Specific… Sufficiently large… Not a special case.’
在开始编码之前,您需要创建一个示例案例。 实际上,您希望有多个测试用例作为示例。 但是您不希望有一个太简单的示例,因为这可能无法涵盖所有测试用例,并且可能会轻易漏掉一个特定的细节。 那么,一个好的例子包括什么呢? 好吧,根据“破解编码采访”,您的示例应为:“特定……足够大……不是特殊情况”。
步骤3:蛮力 (Step 3: Brute Force)
Next up, you want to find the easiest solution you can think of. This will show the interviewer that you are capable of solving the problem. This will also help you gain clarity on the problem and give you some guidance while writing your optimal solution as well. So before you begin spending the time to write the most optimal solution, try to get the easy solution out first.
接下来,您想找到最容易想到的解决方案。 这将向面试官表明您有能力解决问题。 这还将帮助您弄清问题,并在编写最佳解决方案的同时为您提供一些指导。 因此,在开始花时间编写最理想的解决方案之前,请尝试首先获取简单的解决方案。
第4步:优化 (Step 4: Optimize)
At this point, you want to go through your brute force solution and find ways you can optimize your solution. Things to look for?
此时,您想浏览一下蛮力解决方案,并找到优化解决方案的方法。 寻找东西?
- Bottle necks that may be slowing down your code. This is where you want to think about Big O and find ways to speed up runtime. Find ways that you can consolidate steps for better optimization 瓶颈可能会拖慢您的代码。 这是您想了解Big O并找到加快运行时间的方法的地方。 寻找可以合并步骤以进行更好优化的方法
- Eliminate any unnecessary work 消除不必要的工作
- Try to reduce duplicate code. Find areas you may be able to reuse code. This not only can speed up runtime, but looks cleaner to the interviewer. 尝试减少重复的代码。 查找您可能能够重用代码的区域。 这不仅可以加快运行速度,而且对面试官来说看起来更干净。
At this point you ay also want to create new examples to test your code with. You also want to go through the problem and your notes again to make sure your solution accounts for all the details provided.
此时,您可能还想创建新的示例来测试您的代码。 您还希望再次解决问题和注释,以确保解决方案考虑到了所提供的所有详细信息。
步骤5:逐步浏览 (Step 5: Walk Through)
Once you have the most optimal solution, you want to walk through this solution in detail. You want to make sure you completely understand your solution and the problem at hand. Don’t rush to the code without having a solid foundation laid. If you do these first five steps properly, you should be able to complete the coding problem with ease. Write out any pseudocode to help you through the coding process if necessary.
找到最佳解决方案后,您将详细了解该解决方案。 您要确保完全了解您的解决方案和手头的问题。 在没有坚实基础之前,不要急于编写代码。 如果正确执行了前五个步骤,则应该可以轻松完成编码问题。 如有必要,写出任何伪代码以帮助您完成编码过程。
步骤6:实施 (Step 6: Implement)
Up until this point you should not have actually coded anything yet, but you should have a solid foundation and blueprint to build your code on. At this point you will begin writing your code, based on the solution you have created. Be sure your code is neat and error free. Also, be sure to have descriptive variable names. Although variable names such as ‘x’ and ‘i’ may be appropriate for instances such as recording your starting points for iterators, it can lead to confusion when used for other instances.
到目前为止,您实际上尚未编写任何代码,但是您应该具有扎实的基础和蓝图来构建代码。 此时,您将根据您创建的解决方案开始编写代码。 确保您的代码简洁,无错误。 另外,请确保具有描述性的变量名。 尽管诸如“ x”和“ i”之类的变量名称可能适用于诸如记录迭代器起点的实例,但在用于其他实例时可能会引起混乱。
步骤7:测试 (Step 7: Test)
Once you have written your error free code, you should then test your coded solution. You can do this with your example case, but you can also verbally walk through the code to make sure all of the pieces work as you intended them to. To get a quick feel for if your code is written properly, you may want to create a shorter example version for time purposes. It may also be a good idea to test any special cases that may typically cause issues. If you find any bugs, it is perfectly ok to think through the bug and come up with a fix.
编写完无错误的代码后,应该测试编码的解决方案。 您可以使用示例案例来做到这一点,但是您也可以口头遍历代码,以确保所有部分都能按预期工作。 为了快速了解代码是否正确编写,出于时间考虑,您可能需要创建一个较短的示例版本。 测试通常可能导致问题的任何特殊情况也是一个好主意。 如果发现任何错误,则可以仔细考虑该错误并提出解决方案。
Congrats! You made it. These are the seven steps, as provided by the book ‘Cracking The Coding Interview’. Along with these seven steps, it is also highly advised that you are talking through your thought process during each step aloud with your interviewer. This will allow them to see how you think, and may benefit you in certain scenarios, such as if you get stuck, or if you are headed in the wrong direction, or maybe if you don’t finish the code in the allotted time.
恭喜! 你做到了。 这是“破解编码面试”一书提供的七个步骤。 除了这七个步骤,还强烈建议您在与访调员的每一步中大声讨论自己的思维过程。 这将使他们看到您的想法,并在某些情况下使您受益,例如,如果您陷入困境,或者您走错了方向,或者如果您没有在指定的时间内完成代码。
I know that technical interviews can be very daunting, but hopefully these seven steps will help organize your thought process while completing your next coding challenge. Good luck to you all!
我知道技术面试可能会令人生畏,但是希望这七个步骤将有助于您在思考下一个编码挑战时组织思考过程。 祝大家好运!
翻译自: https://levelup.gitconnected.com/7-steps-to-solving-your-technical-interview-problem-e7a77bc863c7
java面试步骤