实例介绍
【实例简介】
Cracking the Coding Interview(6th) 英文原版
【实例截图】
【核心代码】
Introduction Introduction . ........................... • · • . • · · • • · · • · · · · · · · · · · · · · · · · · 2 I. The Interview Process ............. ................... · .. · · . · · · · · · · · · 4 Why? .... ·.................................................... ····· 4 How Questions are Selected .............................................. 6 It's All Relative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Frequently Asked Questions .............................................. 7 II. Behind the Scenes . .......... .................................•..... 8 The Microsof t Interview ................................................. 9 The Amazon Interview ............... , . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 The Google Interview ................................................. 10 The Apple Interview .................................................. 11 The Face book Interview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 The Palantir Interview .................................................. 13 Ill. Special Situations ................................................. 15 Experienced Candidates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Testers and SDETs .................................................... 15 Product (and Program) Management ....................................... 16 Dev Lead and Managers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Startups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Acquisitions and Acquihires ............................................. 19 For Interviewers ..................................................... 21 IV. Before the Interview ............................................... 26 Getting the Right Experience ............................................. 26 Writing a Great Resume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Preparation Map ..................................................... 30 V. Behavioral Questions ..... ...........•...............•...•...•..... 32 Interview Preparation Grid .............................................. 32 KnowYourTechnical Projects ............................................. 33 Responding to Behavioral Questions ........................................ 34 So, tell me about yourself... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 VI. BigO ......................................................... 38 An Analogy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Time Complexity ..................................................... 38 Space Complexity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Drop the Constants ................................................... 41 Drop the Non-Dominant Terms ........................................... 42 VI Cracking the Coding Interview, 6th Edition Introduction Multi-Part Algorithms: Add vs. Multiply ...................................... 42 Amortized Time ............................................ · . . . . . . . . . 43 Log N Runtimes ..................................................... 44 Recursive Runtimes ................................................... 44 Examples and Exercises ................................................ 45 VII. Technical Questions ....................... ...... .................. 60 How to Prepare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 What You Need To Know. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Walking Through a Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Optimize & Solve Technique #1: Look for BUD .................................. 67 Optimize & Solve Technique #2: DIY (Do It Yourself) .............................. 69 Optimize & Solve Technique #3: Simplify and Generalize ........................... 71 Optimize & Solve Technique #4: Base Cas e and Build .............................. 71 Optimize & Solve Technique #5: Data Structure Brainstorm. . . . . . . . . . . . . . . . . . . . . . . . . . 72 Best Conceivable Runtime (BCR) ........................................... 72 Handling Incorrect Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 When You've Heard a Question Before. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 The "Perfect" Language for Interviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 What Good Coding Looks Like . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Don't Give Up! ...................................................... 81 VIII. The Offer and Beyond ....................... ....................... 82 Handling Offers and Rejection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Evaluating the Offer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Negotiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 On the Job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 IX. Interview Questions .............. ......... ........................ 87 Data Structures ....•............. ................................ 88 Chapter 1 I Arrays and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Hash Tables . .......................................................... 88 ArrayList & Resizable Arrays . ............................................... 89 StringBuilder . ......................................................... 89 Chapter 2 I Linked Lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Creating a Linked List .................................................... 92 Deleting a Node from a Singly Linked List . ...................................... 93 The "Runner"Technique .................................................. 93 Recursive Problems . ..................................................... 93 CrackingTheCodinglnterview.com \ 6th Edition VII Introduction Chapter 3 J Stacks and Queues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Implementing a Stock . ................................................... 96 Implementing a Queue . .................................................. 97 Chapter 4 \ Trees and Graphs ............................................. 100 Types of Trees ........................................................ 100 Binary Tree Traversal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Binary Heaps (Min-Heaps and Mox-Heaps) .................................... 103 Tries (Prefix Trees). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Graphs . ............................................................ 105 Graph Search ........................................................ 1 07 Concepts and Algorithms ........................................... 112 Chapter 5 \ Bit Manipulation ............................................. 112 Bit Manipulation By Hand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Bit Facts and Tricks . .................................................... 112 Two's Complement and Negative Numbers . .................................... 113 Arithmetic vs. Logical Right Shift ........................... � ................ 113 Common Bit Tasks: Getting and Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Chapter 6 \ Math and Logic Puzzles ......................................... 117 Prime Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Start Talking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Develop Rules and Patterns . .............................................. 121 Worst Cose Shifting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Algorithm Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Chapter 7 \ Object-Oriented Design ........................................ 125 How to Approach. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Chapter 8 \ Recursion and Dynamic Programming ............................... 130 How to Approach. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 30 Recursive vs. Iterative Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 31 Dynamic Programming & Memoizotion . ...................................... 131 Chapter 9 I System Design and Scalability ..................................... 137 Handling the Questions ................................................. 137 Design: Step-By Step ................................................... 138 Algorithms that Scale: Step-By-Step ......................................... 139 Key Concepts . ........................................................ 140 VI 11 Cracking the Coding Interview, 6th Edition Introduction Considerations ....................................................... 142 There is no "perfect" system ................................................ 143 Example Problem ...................................................... 143 Chapter 10 j Sorting and Searching ......................................... 146 Common Sorting Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 Searching Algorithms . .........•........................................ 149 Chapter11 ITesting ................................................... 152 What the Interviewer Is Looking For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Testing a Real World Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Testing a Piece of Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Testing a Function ..................................................... 155 Troubleshooting Questions ............................................... 156 Knowledge Based ...•.............•.............................. 158 Chapter12ICandC ................................................ 158 Classes and Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Constructors and Destructors .............................................. 159 Virtual Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Virtual Destructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Default Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Operator Overloading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Pointers and References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Templates ........................................................... 163 Chapter 13 I Java ..................................................... 165 How to Approach. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Overloading vs. Overriding ............................................... 165 Collection Framework . .................................................. 166 Chapter 14 j Databases ................................................. 169 SQL Syntax and Variations ................................................ 169 Denormalized vs. Normalized Databases ...................................... 169 SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Small Database Design . ................................................. 171 Lorge Database Design .................................................. 172 Chapter 15 j Threads and Locks ........................................... 174 Threads in Java ....................................................... 174 Synchronization and Locks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Deadlocks and Deadlock Prevention ......................................... 179 CrackingTheCodinglnterview.com I 6th Edition IX Introduction Additional Review Problems ..•...................................... 181 Chapter 16 j Moderate ................. ·................................ 181 Chapter 17 j Hard .................................................... 186 X. Solutions ...... .......................•......•.....•... • , • • • • • 191 Data Structures ..................................................... 192 Concepts and Algorithms ............................................... 276 Knowledge Based .................................................... 422 Additional Review Problems ............................................. 462 XI. Advanced Topics . ................. ...........•..•.........•...... 628 Useful Math ........................................................ 629 Topological Sort ..................................................... 632 Dijkstra's Algorithm ................................................... 633 Hash Table Collision Resolution ........................................... 636 Rabin-Karp Substring Search ............................................. 636 AVL Trees ......................................................... 637 Red-Black Trees ..................................................... 639 MapReduce ........................................................ 642 Additional Studying .................................................. 644 XII. Code Library ..... .............................................. 645 HashMapList<T, E> ................................................... 646 TreeNode (Binary Search Tree) ............................................ 647 LinkedListNode (Linked List) ............................................. 649 Trie & TrieNode ..................................................... 649 XIII. Hints ............... ......................................... 652 Hints for Data Structures ................................................ 653 Hints for Concepts and Alg_orithms ......................................... 662 Hints for Knowledge-Based Questions ....................................... 676 Hints for Additional Review Problems ....................................... 679 XIV. About the Author .......................... .......... ............ 696 Join us at www.CrackingTheCodinglnterview.com to download the complete solutions, contribute or view solutions in other programming languages, discuss problems from this book with other readers, ask questions, report issues, view this book's errata, and seek additional advice
标签: java面试
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论