Amazon Interview Question: Asked to extract numbers from... | Glassdoor

Interview Question

Software Engineer for Industrial and Scientific Store Interview Seattle, WA

Asked to extract numbers from a list of alphanumeric

  strings. For example if string is "qw34rt56", new list should contain 34 and 56. New list should have unique numbers and should be in ascending order. They requested write complete code and tell over the phone.

Interview Answer

2 Answers


I have used TreeSet data structure from Java to accomplish the task.

Interview Candidate on Dec 24, 2009

1. User regular expression to get the different numbers from the string, something like ([0-9]+)[^0-9]
2. Add the numbers to a main array
3. Sort the array.
4. Remove duplicate entries.

Harp B on Jul 13, 2010

Add Answers or Comments

To comment on this, Sign In or Sign Up.