Amazon.com

www.amazon.com

Interview Question

Software Development Engineer Interview Seattle, WA

There was no unexpected or difficult Question. 1. Find the

  first non repetitive character in a character stream. 2. Check for prime number and Elevator system design. 3. Agent bidding system design 4. Find for subtree within a larger tree.
Answer

Interview Answer

3 Answers

0

1.
Character prev = null;
Character current = null;
while(null != (current = getNextChar(stream))){
  if(prev = null){
    prev = current;
  }
  if(prev != current){
    break;
  }
}
//current contains first non repetitive char

Timofey on Jan 25, 2013
0

the stream has assorted characters.. the above solution does not work.

Anonymous on Jan 25, 2013
0

use a hash table and index

Anonymous on Jan 25, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.