Many computer science graduates and programmers have applied for programming, coding and software development positions in start-ups such as Uber and Netflix, large organizations such as Amazon, Microsoft and Google, and service-oriented companies such as Infosys or Luxsoft, but many of them do not know when you apply for jobs in these companiesWhat kind of programming interview questions will you encounter。
In this article, I will share some common programming interview questions from programmers with different experience levels,Including people who graduated from college to programmers with one to two years of experience。
The coding interview mainly includesData structure and algorithm based problems, and some logical problems such as how to exchange two integers without using temporary variables?
I think it is helpful to divide the programming interview questions into different subject areas.The subject areas I often see in interviews are arrays, linked lists, strings, binary trees, and problems arising from algorithms (such as string algorithms, sorting algorithms, such asquicksortOrCardinal sort, and other miscellaneous items), which is the main content you can find in this article.
WeNo guaranteeYou will be asked these programming or data structure and algorithm questions, but they will give you a full understanding of all kinds of questions that can be expected in the actual programming job interview.
Once you know these questions, you should have enough confidence to participate in any telephone or face-to-face interview.
By the way, if youBasic data structure and algorithmIf you don't know enough, or you haven't contacted relevant knowledge for many years, it is meaningless to try these questions.
Less gossip, here is a list of the most frequently asked questions in procedural interviews
1. Array problem
Array is the most commonly used basic data structure, which stores elements in continuous memory.It is also one of the favorite questions in the interviewCode interviewYou will often hear many questions about arrays in, for example, array inversion, array sorting, or finding an element in an array.
A key advantage of array structure is that you can find an element with O (1) complexity when you know the index.But adding or deleting an element is slow, because once you create an array, you cannot change its size.
To create a longer or shorter array, you need to create a new array, and then copy all the elements from the old array to the new array.
The key to solving the array problem is toThe data structure of arrayHave a deep understanding, but also understand the basic program flow such as loops, recursion and basic operators.
Here are some interview questions often asked about arrays, which you can use for practice:
How to quickly find missing numbers in a given integer array from 1 to 100?(Solution)
How to find a duplicate number in a given integer array?(Solution)
How to find the largest and smallest numbers in an unsorted integer array?(Solution)
In an integer array, how can I find a pair of numbers whose sum is equal to a given number?(Solution)
If an array contains multiple duplicate elements, how can I find these duplicate numbers?(Solution)
Using Java to delete duplicate elements from a given array?(Solution)
How to sort an integer array using quick sort?(Solution)
How to delete duplicate elements from an array?(Solution)
How can I delete duplicate elements from an array without using the library implementation?(Solution)
These questions can not only help you improve your problem-solving skills, but also help you improve your understanding of array structures.
If you need more questions about the advanced array, you can refer to《Code interview training camp: algorithm and data structure》This is an algorithm course in the form of training camp, specially designed for interview preparation of technical giants like Google, Microsoft, Apple and Facebook.
If you feel that 10 questions are not enough and you need more contacts, then take a look at this30 array problemsList of.
Linked listIt is another common data structure, which is a supplement to the array structure.Similar to an array, it is a linear data structure that stores elements in a linear manner.
However, unlike arrays, the elements of a linked list are not stored in consecutive locations, but are scattered in various locations in various memory and linked through nodes.
A linked list is a list of nodes containing the memory address of the next node.
Based on this structure, it is easy to add and delete elements in the linked list, because you only need to change the node's direction without creating a new array.However, it is relatively difficult to find an element in a linked list. It takes O (n) time to find an element in a one-way linked list.
For more information on the differences between linked lists and arrays, please readThis article。
Linked lists have several different forms.First is the one-way linked list. In this structure, you can only traverse in one direction (forward or reverse);The second is the double linked list, you can traverse in both directions (forward or backward);Finally, there is a ring linked list, in the form of a ring.
To solve the linked list problem, you must understandrecursionBecause linked list is a recursive data structure.
If you remove a node from the linked list, the remaining data structure is still the linked list. Therefore, many linked list problems have simpler recursive solutions than traversal
The following are some of the most common and popular linked list interview questions and solutions:
How to find the intermediate elements of a single linked list in a single traversal?(answer)
How to verify that a given linked list is circular?How to find the starting node of this ring?(answer)
How to reverse a single linked list without recursion?(answer)
How to remove duplicate nodes in an unsorted linked list?(answer)
How to find the length of a single linked list?(answer)
How to find the third node of a linked list from the end of a single linked list?(answer)
How to use the stack to calculate the sum of two linked lists?(answer)
These problems can help you improve your problem-solving skills and improve your knowledge about linked list data structures
If you still have problems with these linked list coding problems, I suggest you passData Structures and Algorithms: Deep Dive**Using Java * * course to improve your data structure and algorithm skills
All translations in this article are only for learning and communication purposes. Please be sure to indicate the translator, source and link of the article when reprinting.
Our translation work followsCC protocolIf our work infringes your rights and interests, please contact us in time.