What is the difference between pointer and reference? Please describe the two main differences.
C++ Programming Interview Questions
Discuss an algorithm to traverse a tree, depth first.
Implement a function with signature find_chars(string1, string2) that takes two strings and returns a string that contains only the characters found in string1 and string two in the order that they are found in string1. Implement a version of order N*N and one of order N.
Given a circular list of integers (when you reach the end of the list you come back to the beginning), what is the most efficient algorithm to find the smallest integer in the list?
For example: circular_list = [22, 52, 66, 82, 5, 8, 12, 19].
Given a N by N matrix of both negative and positive integers. Write an efficient algorithm to find the sub-matrix with the largest sum of all the contained elements.
Given an array A[N] containing N numbers. Crate an array Output[N] where Output[i] is equal to the product of all the elements of A[N] except A[i].
For example Output[0] is the product of A[1] to A[N-1] and Output[1] is the product of A[0] and from A[2] to A[N-1].
Do this without using the division operator. Do it in O(n).
Write a function that takes an integer and returns the smallest number that is greater than the given number which is a palendrome.
For example, if the input was 111 the next palindromic number would be 121.
Write a function, tokenize_string(input_string, delimiter_list) that returns a list of strings that are separated by the delimiters.
For example: tokenize_string("How now, Mrs. Brown Cow") returns ['How', 'now', 'Mrs', 'Brown', 'Cow']
Write a function that takes as input a sorted array and modifies the array to compact it, removing duplicates. Also return the new length of the array.
Notes: The input array might be very large.
For example:
- input array =
[1, 3, 7, 7, 8, 9, 9, 9, 10] - transformed array =
[1, 3, 7, 8, 9, 10] - size = 6
Write a function to efficiently convert a floating point number to a rational number. For example, given 0.125 return "1/8"
Write a function that takes an unsorted integer array, and returns a three element subset whose sum is zero.
Note: This is a special case of the SUBSET-SUM problem. That problem is NP-complete, but we're only looking for subsets of 3 elements. This can be achieved in polynomial time.
Write a function that takes an array of integers and returns that array rotated by N positions.
For example, if N=2, given the input array [1, 2, 3, 4, 5, 6] the function should return [5, 6, 1, 2, 3, 4]
The least common multiple of a set of integers is the smallest positive integer that is a multiple of all of the integers in the set.
Write a function that takes an array of integers and efficiently calculates and returns the LCM.
Write a function that takes as input two numbers represented as strings, and returns the product of the numbers of a string.
The numbers can be arbitrarily large.
Write a function that takes as input a binary tree, and prints out each level of the tree on a newline. For example:
a
/ \
b c
/ / \
d e f
will output:
a
b c
d e f
Write a function that takes a an array of integers, and returns the contiguous subsequence of integers with the largest sum.
Model the animal kingdom as a set of classes. Discuss the species, their behavior and properties.
Explain the principles of test drive development.