Write a program to reverse a singly linked list? Modify that program to reverse a doubly linked list.
C Facebook Interview Questions
Write a string to find a substring in a given string. Do this in O(n) or better
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 as input a string, and outputs that same string, with any parentheses in it balanced. Do this using the minimum number of edits.
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 a binary tree, and returns the length of the longest path.
For example, in this binary tree:
1 / \ 2 3 / 5
the answer is 2, since the path from vertex 1 to vertex 5 involves two edge traversals.
Write function that takes a binary tree and efficiently returns the Nth smallest element.
For example, if N=4, and the tree looks like:
3 / \ 2 5 / / \ 1 4 6
The function should return 4.
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
a b c d e f
Given a file of size 1TB, containing only 32 bit integers, describe how you would efficiently sort it. You have only 2GB of memory available.
Write a function that takes a an array of integers, and returns the contiguous subsequence of integers with the largest sum.