文件: root - text - article - 2019 - 05 - day-2-week-coding-interview-email-course.txt
标签: 面试技术, 算法, 模式, Interview Course, Computing, Algorithm, Pattern, | 英文 | 主页 | 类别: 计算机科学 | 541 次阅读, 22824 次搜索 | 521 个单词
| 浏览 | 博客存档
标签: 面试技术, 算法, 模式, Interview Course, Computing, Algorithm, Pattern, | 英文 | 主页 | 类别: 计算机科学 | 541 次阅读, 22824 次搜索 | 521 个单词
| 浏览 | 博客存档
This is Day 2/7 of our 1-week coding interview email course.
Yesterday I told you about keeping an algorithmic patterns list as you run through practice coding interview questions.
And I promised to send over the patterns I've found to be most helpful.
Here they are:
"Enumerate all possible solutions, and check them for correctness."
This is usually our first thought when we're breaking down a new problem.
Want to get the highest product of 3 numbers in an array? Grab every set of 3 numbers ("all possible solutions"), multiply them, and keep track of the max ("check them for correctness").
This idea can be applied to most questions, and it's a great way to get from "I have no idea how to even get started" to "I have a way to break down this problem."
The brute force solution is usually not the most efficient, but it can still be a helpful way to start.
By the way, when I say "efficient" I'm talking about "big O time cost." If you're rusty on big O notation (or have no freaking idea what that is), definitely read our explainer.
"Keep track of the best answer 'so far,' in one pass through the input."
This is a common way to go from brute force to something more efficient.
The tricky part is answering the question, "what values will I need to keep updated at each step in order to have the final answer when I reach the end of the input?"
Our stock price question is a good example of this in action.
"Seriously, just use a hash map. Or maybe an array."
Throwing a hash map/hash/dictionary at the problem is actually the answer a lot of the time. If you just make it one of your first thoughts, you'll blow through these kinds of questions.
Hint: it's often a "counts" hash, mapping items to how many times they appear in the input array.
Our "top scores" question is a good example.
One caveat: this approach spends space in order to save time. You can impress your interviewer by noting this tradeoff! (Not sure what "spends space" means? Seriously, read that big O explainer!)
Hopefully these patterns make the algorithm design process feel less abstract. That's our real goal here: to shine a light on the black box of algorithm design.
In those moments where you're not sure how to solve a problem, inspiration doesn't just strike out of nowhere. It comes from the patterns you've built up in your mind.
Devoting conscious effort to building those patterns will take you a long way.
Go ahead and add these three to your running list of algorithmic patterns. You do have your own algorithmic patterns list that you've started, right? C'mon, grab a piece of paper and start one!
Is it starting to feel like you’re getting the hang of this stuff?
There’s still a lot to learn about winning interviews, but stick with Interview Cake and we’ll walk you through everything until it all makes sense.
标签: 面试技术, 算法, 模式, Interview Course, Computing, Algorithm, Pattern, | 英文 | 主页 | 类别: 计算机科学 | 541 次阅读, 22824 次搜索 | 521 个单词 Yesterday I told you about keeping an algorithmic patterns list as you run through practice coding interview questions.
And I promised to send over the patterns I've found to be most helpful.
Here they are:
Brute Force
"Enumerate all possible solutions, and check them for correctness."
This is usually our first thought when we're breaking down a new problem.
Want to get the highest product of 3 numbers in an array? Grab every set of 3 numbers ("all possible solutions"), multiply them, and keep track of the max ("check them for correctness").
This idea can be applied to most questions, and it's a great way to get from "I have no idea how to even get started" to "I have a way to break down this problem."
The brute force solution is usually not the most efficient, but it can still be a helpful way to start.
By the way, when I say "efficient" I'm talking about "big O time cost." If you're rusty on big O notation (or have no freaking idea what that is), definitely read our explainer.
Greedy
"Keep track of the best answer 'so far,' in one pass through the input."
This is a common way to go from brute force to something more efficient.
The tricky part is answering the question, "what values will I need to keep updated at each step in order to have the final answer when I reach the end of the input?"
Our stock price question is a good example of this in action.
Use a Hash Table
"Seriously, just use a hash map. Or maybe an array."
Throwing a hash map/hash/dictionary at the problem is actually the answer a lot of the time. If you just make it one of your first thoughts, you'll blow through these kinds of questions.
Hint: it's often a "counts" hash, mapping items to how many times they appear in the input array.
Our "top scores" question is a good example.
One caveat: this approach spends space in order to save time. You can impress your interviewer by noting this tradeoff! (Not sure what "spends space" means? Seriously, read that big O explainer!)
Hopefully these patterns make the algorithm design process feel less abstract. That's our real goal here: to shine a light on the black box of algorithm design.
In those moments where you're not sure how to solve a problem, inspiration doesn't just strike out of nowhere. It comes from the patterns you've built up in your mind.
Devoting conscious effort to building those patterns will take you a long way.
Go ahead and add these three to your running list of algorithmic patterns. You do have your own algorithmic patterns list that you've started, right? C'mon, grab a piece of paper and start one!
Is it starting to feel like you’re getting the hang of this stuff?
There’s still a lot to learn about winning interviews, but stick with Interview Cake and we’ll walk you through everything until it all makes sense.
猜您喜欢...
- Sort a Partially Sorted List
- Daily Interview Problem: Validate Binary Search Tree
- Detect Linked List Cycle
- Daily Interview Problem: Maximum Profit From Stocks
- [Daily Problem] Add two numbers as a linked list
- Skip the readings, focus on problems. And use all the hints!
- Most Frequent Subtree Sum
- Daily Interview Problem: Jump to the End
- Algorithm Interview: Determine If Linked List is Palindrome
- First and Last Indices of an Element in a Sorted Array
©2006~2024 牛排过熟 - 0.00767 秒 - 2882.845 KB/s - 18 在线 内存: 494.83 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
牛排怎么做才好吃? | <meta name="机器人" content="不索引, 跟踪" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
评论 (0)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。