Amazon

Saturday, February 2, 2008

Algorithm interview questions

[1] Find a linear (O(n) in time) algorithm which does in-place
riffle shuffle of an array of size 2n.

[2] Write a program to check for balanced brackets (and braces, and parentheses)
without using a stack.
"{[]()" false.
"{[]()}" true.
")))(((" false
"((()))" true
"{}([]())" true
"[(]){}" false
Use O(n) time and O(1) space.