Coding interview questions with solutions from top IT companies and hot startups
Table of Contents
⬆ Statement:
Most questions come from IT company interview. Some solutions are NOT my
original work, but I don't know who wrote them. Difficulty of questions changes greatly, and the special topics include several advanced ones.
Total Number (not including the problem in the special topics) of Problems: about 210 (120 done).
Although I try to execute every program, bugs may still exist because I didn't run enough tests, welcome to find bugs.
The solution may not be optimal, welcome to give your better solution. You can send the corresponding pull request.
By default, the time complexity indicates the worst time and the space complexity doesn't include the stack space.
⬆ Problem:
⬆ Array:
- Calculate the rotation distance for a sorted rotated array
- Celebrity problem
- Detect cycle in an array
- Detect the longest cycle in an array
- Diagonal elements sum of a spiral matrix
- Find a partition in an array to minimize the sum of two parts
- Find a small rectangle with four corners one in a large rectangle
- Find elements in the first array but not in the second one
- Find independent parts in an array
- Find the id with most posts
- Find the largest sum of three integers in a row in an array
- Find the longest consecutive increasing subarray in a grid
- Find the maximal item a[i], such that a[i]=a[x]+a[y] in an array
- Find the minimal difference between two sorted arrays
- Form an ascending array by removing elements from an existed array
- Given an array a[i], build b[i] = a[0]a[1]…a[n-1]/a[i]
- Given an array and a number k, check if there exists an element arr[i] such that its duplicates lies in arr[i-k] and arr[i+k]
- Given an array of size n, the array contains numbers in range from 0 to k-1 where k is a positive integer and k s3 s5 <s6 ...
- Given an unsigned integer array with size n, the sum of array equals a, calculate a number k such that the sum of array becomes b when all numbers in the array greater than k is replaced by k
- Given m number of sets, generate a new array arr (size m), where a[i] comes from set i, output all possible new arrays
- Given three arrays, select each number a, b, c from each array to minimize max(a-b,b-c,c-a)
- Given two binary arrays A and B, i.e., containing only 0s and 1s each of size N. Find indices i, j such that sum of elements from i to j in both arrays is equal and j-i (i.e. the length of the set i,j) is the maximum possible value
- Length of first subarray that sums to zero in an array
- Length of shortest subarray with sum greater than s in in array
- Nearest greatest element in an array
- Print all K-complementary in an array
- Recover the queue
- Running average in a sliding window
- Stable two way partition
- Water flow path
--
⬆ String:
--
⬆ Linked List:
--
⬆ Heap:
--
⬆ Tree:
--
⬆ Math: