This paper mainly introduces some questions about algorithm interview and how to prepare for algorithm interview

Algorithmic interviews are more than just answering questions correctly

There is a reasonable way to think about most questions you encounter in an interview

What is an algorithmic interview?

  • Let everyone in the face of the algorithm problem in the interview, there is a reasonable way to think:
  • It does not mean that you can answer every algorithmic question “correctly”, but reasonable thinking direction is actually more important, which is also the premise of correctly completing algorithmic interview questions
  • A good algorithmic interview does not mean a good technical interview
  • A good technical interview doesn’t mean you’ll get a job Offer

What is giving a reasonable way of thinking?

  • The goal of algorithmic interviews is not to give a “correct” answer,
  • It’s about showing the interviewer how you think.

“Right” is itself a relative concept

  • Algorithmic interviews are not sats.
  • Think of it as working with your interviewer on a solution to a problem.
  • Communicate the details of the question and the context in which it will be applied.
  • This communication is important in and of itself, and it has implications for the way you think about things.

example

We need to sort a set of data

  • Design sorting interface, standard library design, sorting algorithm in business.
  • Sorting is fundamental. It’s important.

To solve

Quick sort algorithm: O(nlogn)

  • Ignoring the underlying environment in which the algorithm is used. Choose dynamically.

(Question to interviewer): What are the characteristics of this data set?

  • Is it possible to have a lot of repeating elements?
  • If this is possible, the three-way fast platoon is a better choice.
  • Plain data: Plain quicksort will do; Java language standard library sort using three-way quicksort.
  • Is most of the data close to its correct location? Is it almost orderly?
  • If so, insert sort is a better choice.
    • In order of business occurrence, occurrence first, completion first, almost orderly, insertion sort is a better choice.
  • Is there a very limited range of values? Like ranking student grades.
    • If so, counting sort is the better choice. Gaokao scores have a limited range: counting sort is better.

(Question to interviewer): Are there any additional requirements for ranking?

  • Do you need a stable sort?
    • If so, merge sort is a better choice.

(Question to interviewer): How is the data stored?

  • Is it stored using a linked list?
    • If so, merge sort is a better choice.
    • Fast sorting relies on random access to arrays.

(Question to interviewer): How is the data stored?

  • Can the data size be loaded in memory?
    • There is too much data, or too little memory to load in memory, and you need to use an external sorting algorithm.

Sort a summary of a set of data

  • Is it possible to have a lot of repeating elements?
  • Is most of the data close to its correct location? Is it almost orderly?
  • Is there a very limited range of values? Like ranking student grades.
  • Do you need a stable sort?
  • Is it stored using a linked list?
  • Can the data size be loaded in memory?

What is the “correct” answer to an algorithmic question

  • Correct except that you can write the code and run it correctly. Being right involves having an original view of the problem; Optimization; Code specification; Fault tolerance;
    • Not only give the code to solve the algorithm problem, but also include the above factors.
    • If it’s really hard, it’s also hard for your competitors.
  • The key is how you communicate how to solve the problem.
  • Even by expressing the direction of solving the problem, I can reach a conclusion: what field should be the solution to the problem? I can solve the problem through consulting or further learning.

Algorithmic interviews are only part of the interview

  • Algorithmic interviews are just one part of technical interviews.
  • Depending on your resume and the position you’re applying for, it’s important to look at other technical aspects.
  • Project experience and practical problems encountered in the project
    • Problem-solving ability, participation or not
    • Deep thinking
    • Technology of attitude

Comb through the items on your resume before the interview: Sort out any questions that might come up.

  • What’s the most memorable bug you’ve encountered?
  • object-oriented
  • Design patterns
  • Network correlation; Safety related; Memory dependent; Concurrent correlation; …
  • System design; The scalability of the enterprise

A good technical interview doesn’t mean you’ll get a job Offer

The technical interview is only part of the interview. The interview is not just about your technical skills, but also about your past and the way you think and act.

  • About the past: Participation in projects is critical

Project Experience:

  • People in the work
  • A graduate student
  • undergraduates
    • Graduation design
    • Other course design (large assignments)

How do I find projects?

  • internship
  • Create your own project
    • Make your own mini-apps: to-do lists; The memo. Player…
    • Solve your own little problems: crawlers; Data analysis; Word frequency statistics…
    • “Not a project” project: an excellent technical book on code cleaning… (lot)
    • Share: Own tech blog; Making, etc.

Behavioral problems

Learn from the past how you think and act:

  • What are your biggest challenges?
  • Mistakes made?
  • Failure?
  • What do you enjoy most about your job?
  • How to deal with conflicts?
  • The most unusual thing you’ve ever done?

I encountered an algorithm problem in the so-and-so project: What is the problem? It was the biggest challenge I ever faced, how I overcame it.

Prepare appropriate questions to ask the interviewer

  • What is the general operation mode of the whole group?
  • What is the follow-up planning of the whole project?
  • How is a problem solved in this product?
  • Why do you choose certain technologies? Standards?
  • I am interested in a particular technology. What opportunities will I have in your group to delve into that technology?

Algorithmic interviewing is still a very important part of it

How to prepare for an algorithm interview

Preparing for an interview and preparing for an algorithmic interview are two different concepts

  • Algorithmic interview is just one part of the interview process.
  • You don’t have to finish an Introduction to Algorithms.
    • Emphasis on theoretical proof
    • You don’t need to understand the proof on the first reading
    • The first few readings should remember the conclusion, not the proof. Put more energy into algorithmic ideas.
  • For algorithm interviews, the theoretical derivation and proof in introduction to algorithms are not very important aspects.

Learn to remember perfectionism

  • Advanced data structures and algorithms are rarely mentioned in interviews

  • The basic concepts need to be known, but the deeper level of implementation is not required.
  • Far from reaching the level of an informatics competition

Scope of preparation for algorithmic interviews

  • Don’t underestimate basic algorithms and data structures and focus only on “interesting” topics
  • Various sorting algorithms
  • Implementation of basic data structures and algorithms: such as heap, binary tree, graph…
  • Use of basic data structures: such as linked lists, stacks, queues, hash tables, graphs, Trie, and lookup sets…
  • Basic algorithms: depth first, breadth first, binary search, recursive…
  • Basic algorithm ideas: recursion, divide and conquer, backtracking, greedy, dynamic programming…

example

Intel interview questions:

Heap sort is adopted for a group of numbers whose initial sequence is 1, 8, 6, 2, 4, 7, 3. When the construction of heap (small root heap) is completed, the sequence traversal sequence in the binary tree corresponding to the heap is :()

A. 8 3 2 5 1 6 4 7

B. 3 2 8 5 1 4 6 7

C. 3 8 2 5 1 6 7 4

D. 8 2 3 5 1 4 7 6

Leeco’s interview questions:

Binary search for an ordered array of 20 elements, starting with subscript 1, the comparison sequence of A[2] is found with subscript ().

9, 5, 4, 2

B. 10, 5, 3, 2

C. 9, 6, 2

D. 20, 10, 5, 3, 2

Examine the binary search method.

Alibaba Interview Questions

If the sorting code of a group of records is (5, 11, 7, 2, 3, 17), the initial heap established by heap sorting method is ().

(11, 5, 7, 2, 3, 17)

(11, 5, 7, 2, 17, 3)

(17, 11, 7, 2, 3, 5)

(17, 11, 7, 5, 3, 2)

E. (17, 7, 11, 3, 5, 2)

F. (17, 7, 11, 3, 2, 5)

Baidu Interview Questions

When the graph is stored by adjacency list, the time complexity of Prim algorithm for minimizing spanning tree is ().

  • O(n)
  • O(n+e)
  • O(n^2)
  • O(n^3)

Focus on the

  • Use of basic data structures: such as linked lists, stacks, queues, hash tables, graphs, Trie, and lookup sets…
  • Basic algorithms: depth first, breadth first, binary search, recursive…
  • Basic algorithm ideas: recursion, divide and conquer, backtracking, greedy, dynamic programming…

Choose the appropriate OJ (Online Judge) : Online question judging system

  • Do not choose an OJ * that is too biased towards programming competitions and too difficult for contests

  • Choose the right O.J.

  • leetcode

    • Online Portal for IT Interview
    • Real interview questions
    • www.leetcode.com
  • HankeRank

    • It is characterized by a detailed classification of problems. Partial difficult, but can solve a certain kind of subdivision problem.
    • www.hackerrank.com

Pay attention to

  • A balance should be struck between study and practice
  • Basic algorithm realization and algorithm thought

How to Answer algorithmic interview questions

The whole idea of solving algorithmic interview problem

  • Pay attention to the conditions in the question
    • Given an ordered array… (Dichotomy)
  • Some of the conditions in the questions are essentially suggestive
    • Design an O(nlogn) algorithm (divide and conquer: complete tasks in a search tree, for sorting data)
    • No extra space to consider (space for time optimization)
    • The data size is about 10000 (O(n^2))

When there are no ideas

  • Give yourself a few simple test cases to experiment with
  • Don’t ignore the brute force solution. Violent solutions are often the starting point for thinking.

example

LeetCode 3 Longest Substring Without Repeating Characters

Search for the oldest string in a string with no repeated letters such as “abcabcbb”, result is “ABC” such as “BBBBB”, result is “b”

  • For substring s of string s[I…j]

  • Using O(n^2) algorithm to traverse I,j, can obtain all substring s[I…j].

  • The algorithm O(length(s[I…j])) is used to determine whether s[I…j] contains repeated letters

  • Triple loop: complexity O(n^3), for n=100 data, feasible

Optimization algorithm

  • Traverse common algorithm ideas

  • Walk through common data structures

  • Interchange of space and time (hash table)

  • Preprocessing information (sorting)

  • Look for the answer at the bottleneck: O(nlogn) + O(n^2); O(n^3)

    • O(n^2) can be optimized.
  • What kind of ideas and data structures are used for what kind of problems.

Actual writing problem

  • Judgment of extreme conditions

    • Array empty?
    • String is empty?
    • The quantity is zero, right?
    • A pointer to NULL?
  • Code specification:

    • The variable name
    • modular
    • reusability

— — — — — — — — — — — — — — — — — — — — — — — — — gorgeous line — — — — — — — — — — — — — — — — — — — —

After watching the friends can click a like/follow, your support is the biggest encouragement to me.

Personal blog tomato technology small stack and gold digging home page

If you want to know more, please follow my wechat official account: Tomato Technology Xiaozhan