Курс лекций для подготовки к олимпиадам по программированию Решение задач на время, или Cracking the Coding Interview Глухих Михаил Игоревич, к.т.н., доц. mailto:
Cracking the Coding Interview It’s a book! Gayle Laakmann Downloadable Основы программирования на языках C и C++ 2
General principles Stages Resume collection Phone screening On-site interview Homework Questions Behavioral Technical Основы программирования на языках C и C++ 3
Must have Structures: vectors, linked lists, trees, stacks, queues, hash tables Algorithms: BFS, DFS, binary search, merge & quick sort, simple tree operations Concepts: bit manipulation, singleton & factory patterns, memory types (stack, static, heap), recursion, big O Language & library details: inheritance, polymorphism, multithreading, etc. Основы программирования на языках C и C++ 4
Some interviews from personal experience… JetBrains Mostly questions about “what does this code” and “how good is it” Homework Which language is it? What’s the longest common substring? Intel Specific questions about finite automata and SystemC General C++ & OOP questions Facebook / Microsoft Основы программирования на языках C и C++ 5
General rules Some decision is better than no decision Do it first Good decision is better than some decision Remember about time and memory consumption Основы программирования на языках C и C++ 6
Algorithms approaches Examplify Angle between hour & minute hands Pattern matching Find the minimum in a rotated sorted list like this: Simplify & generalize Is it possible to make a given ransom note from given newspaper words? Base case & build (induction) Print all permutations of a string Data structure brainstorm Keep track of a median in an extending list Основы программирования на языках C и C++ 7
Additional task #1 Are two strings anagrams? Основы программирования на языках C и C++ 8
Additional task #2 Design a stack that can push, pop, and get minimum Limitation: all three operations should work in O(1) time Основы программирования на языках C и C++ 9
Additional task #3 Find the first common ancestor of two given nodes in a binary tree Основы программирования на языках C и C++ 10