Search this site
Embedded Files
Skip to main content
Skip to navigation
James Chen's C/C++ Home
Interview questions -- think in C/C++ by James Chen
Array
Calculate how much water contained by jth glasses -- Amazon
Compute sum of two digit arrays
Compute the frequency of each element in an array -- Amazon
Compute the mins and maxes
Compute the sum of elements in after nth iteration -- Amazon
Compute the union and intersection of two arrays -- Ebay
Display row number \ column number having the maximum sum and the minimum sum -- Amazon
Fill the array with product of all numbers except the number in that cell -- Google
Find all pair of number in array which sum to a specified value
Find indices i,j such that Sum of elements from i to j in both arrays is equal and j-i -- Amazon
Find indices i,j such that Sum of elements from i to j in both arrays is equal and j-i -- Amazon(2)
Find max benefit in best time complexity -- Amazon
Find min diff = |a-b| + |b-c|+|c-a| -- Amazon
Find the best buy and sell time that make max benefit
Find the continuous sequence with the largest sum
Find the equilibrium position of the array -- Amazon
Find the largest subarray with equal number of 0's and 1's
Find the longest subset with consecutive numbers -- Google
Find the majority number -- Google
Find the maximum contiguous subsequence product -- InMobi
Find the maxProduct of three numbers from a given integer array -- Amazon
Find the median in two sorted array -- Amazon
Find the most longest or most frequent longest subarray -- Amazon
Find top 5 largest numbers from 3 sorted arrays
Find two disjoint contiguous sub-arrays such that the absolute difference -- Google
Find two missing numbers (method 1) - Siemens
Given an array of NxN, print its diagonals from top-right to bottom-left.
Is the rotated matrix same? -- Google
Josephus problem
Merge these two sorted arrays without using a third array
Print an array in spiral format -- Microsoft
Print max sequences in a matrix -- Amazon
Print the numbers of form 2^i.5^j in increasing order -- Google
Print the numbers without repeating digits
Print visible trees
Randomly select an element from an array
Remove duplicates in prime numbers -- Amazon
Remove repeated values form an integer array -- IQ
Rotate a matrix by 90 degrees
Set elements to zero if an element in the same row or col is zero
Sort array without second loop
Sum of an array with adding/subtracting operations on all the elements.
Sum of an array with adding/subtracting operations on all the elements[1]
Transpose an integer array
Bit manipulation
Addition without arithmetic operations
Bit count - how many 1's in an integer - Microsoft
Compute how many bits to require convert one integer to another
Compute parity
Compute the ceiling power of 2
Compute the minimum number of bits to store a * b + c -- NVIDIA
Determine a number is a power of 2
Find missing number in an array with continuous number
Find nearest number with same number of 1 bit in binary presentation
Find two's compliment of a negative number -- Amazon
Generate 8-b ints with specified 1's
Implement a binary presentation of a decimal(integer and floating point number))
Reverse bits in an integer
Reverse bits of an integer (Method 2)
Swap odd bits and even bits
Swap two numbers without temporary variables
Write a method to set all bits between i and j in n equal to m
C
Compute the factorial of a large number
Compute the possibility of random generation - Simens
Distribute coins -- Adobe
Find how many ways can you make an amount ‘x’ -- Microsoft
Find the maximum of two number without if-else instructions
Generate random between 1..7 -- Google
Is there any possibility to execute a function after main()?
Print a spiral array
Print a triangle
Print Pascal triangle
C++
Access private members of base class
Design and implement a class to record logging messages - IKM
Member pointer
Name hiding
Codibility
01.01 BinaryGap
08.01 EqualLead
08.02 Dominator
09.01 MaxProfit
09.02 MaxDoubleSliceSum
09.03 MaxSliceSum
10.1 CountFactors
10.2 MinPerimeterRectangle
10.3 Peaks
10.4 Flags
15.1 AbsDistinct
15.2 CountDistinctSlices
15.3 CountDistinctSlices
15.4 MinAbsSumOfTwo
16.1 MaxNonoverlappingSegments
16.2 TieRopes
2.1 CyclicRotation
2.2 OddOccurrencesInArray
3.1 FrogJmp
3.2 TapeEquilibrium
3.3 PermMissingElem
4.1 FrogRiverOne
4.2 PermCheck
4.3 MissingInteger
4.4 MaxCounters
5.1 CountDiv
5.2 PassingCars
5.3 GenomicRangeQuery
5.4 MinAvgTwoSlice
6.1 Distinct
6.2 Triangle
6.3 MaxProductOfThree
6.4 NumberOfDiscIntersections
7.1 Fish
Definition and concepts
Const, pointer and typedef
Increment & Decrement
Precompile
sizeof
union
volatile
Design Patterns
Builder Pattern
Implement a factory to create operating system
Implement a singleton class
Visitor Design Pattern
Dynamic programming
Find how many ways can you make an amount ‘x’ -- Microsoft
Find longest increasing subsequence -- Yahoo
Find minimum coin changes -- Amazon
Find the longest path of 1s available in the matrix -- Goldman Sachs
Embedded Programming
Fundamentals of embedded programming
File and iostream
Add these two numbers and write in third file with the help of given functions only -- Amazon
Find the unique line in not more than one scan of the file -- Amzon
Print last n sentences in a text file
Print numbers in specified format
Graph
Find a way that each intermediate word exist in a given dictionary -- Ebay
LeetCode
104. Maximum Depth of Binary Tree
136. Single Number
59. Spiral Matrix II
66. Plus One
Linked list
Add two lists
Correct a sorted linked list with a reversed sublist -- Microsoft
Cut off circular linked list node
Delete a node in the middle of list
Flatten and deflatten doubly-linked list
List the last n nodes
Merge two ascendant singly-linked list
Print list, last node should still point to the middle node of the updated linkedlist -- Microsoft
Remove duplicate nodes in an unsorted singly-linked list
Reverse singly-linked list
Sort integer linked list -- Amazon
Swap kth element from the beginning and kth element from the end of linked list -- Amazon
Low level
2D memory allocation
Endianess
Memory operation with alignment
Math
Compute determinant
Compute jars combination
Compute PI
Detect whether two rectangles have common area or not -- Amazon
Find the kth number divisible by only 3 or 5 or 7 -- Microsoft
Find the kth number such that the only prime factors are 3, 5, and 7
Generate true of false with specifed probability -- Facebook
Multi-threading
Simple threaded program(Linux - pthread)
Thread synchronization using semaphore (Linux)
Number and string
Calculate the nth prime number -- Ebay
Calculate the sum of long numbers
Compute the number of iteration -- Nvidia
Compute the number of trailing zeros in N-factorial
Convert a base 2 number to a base 4 number -- Microsoft
Convert integer to string
Convert string to integer
Count the number of positive integers less than N that does not contains digit 4 -- Google
Find all prime numbers in a range of (1..1000))
Find next number which has same sum of digits
Find nth largest element in an array of m elements where n->0 (n is much smaller than m) without sorting -- Amazon
Find the label in Excel -- Amazon
Find the max no that can be formed by any permutation of the arrangement -- Amazon
Find whether a given number is a perfect square or not -- Microsoft
Format Number - 1
Format Number - 2
Given an integer N, print numbers from 1 to N in lexicographic order -- Bloomberg LP
How to solve this ((3000000!)/(30!)^100000)%(any prime no.) -- Adobe
Pretty Number Formatting
Print the numbers between 30 to 3000 -- Microsoft
SIMD simulation -- Ittiam
SIMD simulation --Method2 -- Ittiam
Translate number into English phrases
Recursion
Calculate (x^y)%z without pow() -- Google
Compute bionomial coefficients
Compute how many times 10 shootings makes 90
Compute number of 2s in a range of (0...n)
Compute the nth Fibonacci number
Eight queens
Find changes - Amazon
Find the number of ways to make the sum S if dices are rolled together -- Google
Find the occurences of a specified word in a matrix -- Amazon
Find the subset whose sum is exactly half of the total sum -- Yahoo
Generate strings with a specified pattern -- Google(Recursive)
Hanoi Tower
Is an array ascendent
List all subset of a set
Number maze
Permutation
Print changes(Knapsack)
Print combinations of a string
Print n-pair parentheses
Print the indices of all the combination -- Accenture
Robot path
Truth Table implementation -- (Microsoft) - recursion -- Method 1
Regular expression
Find strings with a consecutive repetition of a specified letter - Ibibo
Match words
Search
Find a number in the array having least difference with the given number (n) -- Facebook
Find a tuple in ascending order -- Flipkart
Find an element in a rotated sorted array
Find an element in a sorted matrix
Find an element whose value is equal to its index.
Find and replace a specified pattern -- Microsoft
Find minimum absolute difference btween two numbers in 2 arrays -- Amazon
Find minimum number of players that the total followers equal to K -- Amazon
Find no of 'a' words in a sentence -- Microsoft
Find period when maximum number of animals lived -- Amazon
Find string in a sorted array interspersing with spaces
Find the character with the second highest frequency -- Twitter
Find the existence of 2 elements in array sum which equals to k -- Adobe
Find the first element in a sorted array
Find the first occurrence of this number (index) in this array without using linear search -- Amazon
Find the start and end indexes of the number in the array
Find the strategy that has the highest pay off -- Bloomberg
Find triple -- Google
Find triplets in an array that sum to zero -- Google
Saddleback Search -- Amazon
Sorting
Bubble sort and Shell sort
Dutch national flag
Merge 3 sorted arrays
Merge sorted arrays
Quick sort
Selection sort
Sort an array of strings(anagram)
Sort an array which only has 0's and 1's. Do not use count sort -- Microsoft
Sort an array with unique elements -- Microsoft
Sort this array in a way reserving the relative position -- Google
Three ways sorting - Yahoo
Stack
Implement stack using multiple stacks with limit capacity
Sort a stack
Use a single array to implement 3 stacks
Use two stacks to implement a queue
STL
Compute the multiples of two integers in a range
Find a 1st non-repeated char in the string
Find a 1st non-repeated char in the string
Find a missing number in a list
Find a missing number in an array
Find all pair of number in array which sum to a specified value[Method 2]
Find anagrams of a specified word in a dictionary
Find common strings in two lists
Find dictionary order -- Google
Find pairs equal zero -- Paypal
Find the first nonrepeated character
Find the greatest common integer in two unsorted arrays -- Amazon
Find the major number [Hash map] -- Amazon
Find the number of couples with the same difference
Find the numbers -- Amazon
Find ways to stack four cubes
Generate numbers from 2^i * 3^j * 5^k * 7^l in sorted order[STL] -- Google
Generate the maximum number using the digits in the array such that it is divisible by 2, 3 and 5
Given an array of integers and an integer k. Returns the pairs that subtract result in k. Example: 3,6,10,13. (3,6),(10,13)
Mapping words -- Facebook
Print all the sub sets of the array which have sum >=k -- Amazon
Print ordered chars with specified format -- Google
Print truth table -- Microsoft (Non-recursive) -- Method 2
Remove specified characters
Set cover
Truth Table implementation -- Microsoft - non-recursive -- Method 3
String
Convert IP address(32-bit) into string format
Count the total number of contiguous substrings -- Adobe
Create a new string with duplicates of each character in the original string and append the reverse of the same string (with duplicates) excluding the last character
Determine a string is a rotation of another
Determine whether a string has unique characters
Determine whether two strings are anagrams
Find a missing number in a string -- Amazon
Find max common string at the beginning
Find the first non repeating character in a given string -- Microsoft
Find the largest number obtained by rearranging the digits in O(n) time - Amazon
Find the longest common substr
Find the longest running sequence of a character among all possible permutations of the strings in the array -- Amazon
Find the maximum length of continuous subarray with at max 3 unique numbers
Generate strings with a specified pattern -- Google
KMP Search
Match words -- Google
Move the spaces to the starting of the string in single iteration -- Microsoft
Print the index of a word with letters in ascending order -- Microsoft
Remove blanks in the head and tail of a string
Remove duplicate characters in a string
Remove specified characters from a string
Replace spaces in sentences with "%20"
Replace string in specified patterns
Reverse a sentence but do not reverse words
Reverse a string
Run length encoding
Select movie -- Google
Test and change a string -- Amazon
Write your strcat
Tree
Create a balanced binary tree
Determine a binary tree is balanced
Find out the maximum sum of value from root to each leaf -- Bloomberg LP
Find the intersection of two arrays with No Hash -- Microsoft
Find the maximum j - i such that A[j] > A[i] -- Yahoo
Mirror a binary tree
Print D-Level nodes in a binary tree
Print the sum of k^0, k^1, k^2, k^3 in level n of a binary tree -- Adobe
Traverse a binary tree
Untitled page
Interview questions -- think in Visual C++ / CLI by James Chen
Collections
Calculate how much water contained by jth glasses -- Amazon
Security
Identity and Principal
Role and Claim
Signature
Lists
Miscellaneous
.Net
Dynamic change where predicate in LINQ
Audio
Play Music with Media Control Interface(MCI)
Bash
Block all connections
Dump yum history
Get bash script parent path
Hide network interface
Locate file and display its details
Set timezone
Sort applications by open file number
DirectShow
FFMPEG
Get Video Frame Number and Druation
GUI
Image
Convert String to Image
Display image planes[MATLAB]
Linux
Disable gnome keyring
ECDSA host key for 10.1.1.23 has changed and you have requested strict checking.
locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory
No package 'json-glib-1.0' found on Ubuntu
No package 'libxml-2.0' found on Ubuntu 18
scp without inputting password
sudo: apt-add-repository: command not found
You must put some 'deb-src' URIs in your sources.list
Python
Activate and deactivate pyenv
Avoid subprocess sleeping
Qt
Display an image with OpenCV 2.4.6 on Qt 5
Render a media file with DirectShow [Qt Console Application]
Video
VirtualBox
Install CentOS 7 from network
Shared libs in /usr/local/lib cannot be found
TypeScript
TypeScript is not running
Windows
PowerShell
Recent Posts
Calculate (x^y)%z without pow() -- Google
Calculate how much water contained by jth glasses -- Amazon[CLR]
Calculate how much water contained by jth glasses -- Amazon[Native C/C++]
Calculate the sum of long numbers
Compute min and max
Compute sum of two digit arrays
Compute the ceiling power of 2
Compute the frequency of each element in an array -- Amazon
Convert a base 2 number to a base 4 number -- Microsoft
Convert IP address(32-bit) into string format
Correct a sorted linked list with a reversed sublist -- Microsoft
Count the number of positive integers less than N that does not contains digit 4 -- Google
Count the total number of contiguous substrings -- Adobe
Distribute coins -- Adobe
Fill the array with product of all numbers except the number in that cell -- Google
Find a missing number in a string -- Amazon
Find a number in the array having least difference with the given number (n) -- Facebook
Find a tuple in ascending order -- Flipkart
Find all pair of number in array which sum to a specified value[Method 2]
Find how many ways can you make an amount ‘x’ -- Microsoft
Find how many ways can you make an amount ‘x’[DP] -- Microsoft
Find indices i,j such that Sum of elements from i to j in both arrays is equal and j-i -- Amazon
Find indices i,j such that Sum of elements from i to j in both arrays is equal and j-i -- Amazon
Find longest increasing subsequence -- Yahoo
Find max benefit in best time complexity -- Amazon
Find min diff = |a-b| + |b-c|+|c-a| -- Amazon
Find minimum absolute difference btween two numbers in 2 arrays -- Amazon
Find minimum coin changes -- Amazon
Find minimum number of players that the total followers equal to K -- Amazon
Find out the maximum sum of value from root to each leaf -- Bloomberg LP
Find the best buy and sell time that make max benefit
Find the character with the second highest frequency -- Twitter
Find the equilibrium position of the array -- Amazon
Find the intersection of two arrays with No Hash -- Microsoft
Find the kth number divisible by only 3 or 5 or 7 -- Microsoft
Find the kth number such that the only prime factors are 3, 5, and 7
Find the label in Excel -- Amazon
Find the largest subarray with equal number of 0's and 1's
Find the longest path of 1s available in the matrix -- Goldman Sachs
Find the maximum j - i such that A[j] > A[i] -- Yahoo
Find the maximum length of continuous subarray with at max 3 unique numbers
Find the number of couples with the same difference
Find the numbers -- Amazon
Find the occurences of a specified word in a matrix -- Amazon
Find the start and end indexes of the number in the array
Find the subset whose sum is exactly half of the total sum -- Yahoo
Find top 5 largest numbers from 3 sorted arrays
Find two's compliment of a negative number -- Amazon
Find ways to stack four cubes
Format Number - 1
Format Number - 2
Generate numbers from 2^i * 3^j * 5^k * 7^l in sorted order[STL] -- Google
Given an array of integers and an integer k. Returns the pairs that subtract result in k.
Given an integer N, print numbers from 1 to N in lexicographic order -- Bloomberg LP
Mapping words -- Facebook
Match words -- Google
Merge 3 sorted arrays
Number maze
Print all the possible paths top to down -- Yahoo
Print all the sub sets of the array which have sum >=k -- Amazon
Print list, last node should still point to the middle node of the updated linkedlist -- Microsoft
Print numbers in specified format
Print ordered chars with specified format -- Google
Print the index of a word with letters in ascending order -- Microsoft
Print the indices of all the combination -- Accenture
Print the numbers between 30 to 3000 -- Microsoft
Print the numbers without repeating digits
Print the sum of k^0, k^1, k^2, k^3 in level n of a binary tree -- Adobe
Run length encoding
Saddleback Search -- Amazon
Select movie -- Google
Set cover
Sort an array with unique elements -- Microsoft
Sort integer linked list -- Amazon
Sum of an array with adding/subtracting operations on all the elements[1]
Test and change a string -- Amazon
Visitor Design Pattern
James Chen's C/C++ Home
Number and string
Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse