Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

I also forgot grep when I was asked this question in an interview. I said I would write a Java program with the PatternMatcher. The interviewer said "Well your method if fine if we need to repeat it several times but for once, you can use grep".

- Prathibha Hegde June 08, 2005 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

With this question they just want to know if you know about any scripting languages.. any scripting language will do bash/python/perl. c++/java code in this Q may reduce your chances of getting selected unless its an astonishing solution

If its just for one time then following grep command like:

grep -lr '[1-9]\{3\}-[0-9]\{4\}-[0-9]\{3\}' "*.html" > results.txt

- vik September 11, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The answer expected for this rather challenging algorithms questions is "grep"!

- Sam May 15, 2005 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Yeah I was a little confused when I got the question, because I didn't see where the challenge was... I think I ended up just saying something about using a regular expression. You're right that this question may be just aimed at testing UNIX proficiency - it may also be about to what degree will you ask questions to clear up ambiguity (I know microsoft likes doing that).

- Gayle L McDowell May 15, 2005 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

grep -lr '\d\d\d(-)?\d\d\d(-)?\d\d\d\d' *

actually, it is hard to have a regular exp. for all phone patterns....

- someone November 15, 2005 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

grep -lr "[[:digit:]]\{3\}[-]\?[[:digit:]]\{3\}[-]\?[[:digit:]]\{4\}" *

- yoyo March 08, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

grep -lr "[0-9]\{3\}[ -][0-9]\{3\}[ -][0-9]\{4\}"*
this would return numbers of the format 123-456-7890
but would also return 123-456-78901
is there a way to restrict the digits to a specic number, coz when we specify 3 it means minimum 3

- pranjal April 15, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

how about{3,3}?

- Anonymous September 01, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

For those who wanna know more about grep..

- Pavan B June 15, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For those who wanna know more about grep..

http://www.computerhope.com/unix/ugrep.htm

- Pavan B June 15, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I had a problem with Grep when there were too many files. It gave me an exception that there are too many files. So I had to use a commbination of "find" and "exec" to locate all the files that I was looking for. something like: (can't remember exactly)

find . -name ".html" | exec ...pattern matching... /?

I am not sure if I did something wrong here..

- Chiru October 03, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

here is a correction to my above post..
find . -name ".html" - exec grep 'your pattern' '{}' \;

- Chiru October 30, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

find . -name ".html" | exec ...pattern matching... /?

Right! But here exec should be used as a command within find, not independently (like xargs)...
So we use a hyphen instead of pipe

find . -name ".html" - exec grep -f <pattern> {} \;

- Jana January 23, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If I think this in terms of .Net then I would open up each html file as an XMLDocument, do an XPath query to check if such an XmlNode exist. If yes, will check if the XmlNode has any InnerText (which in this case will be the phone no.). If yes, then will add this file to the List<String> collection.

- Priyadarshan February 14, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

find . -name *.html | xargs grep "[0-9][0-9][0-9][-][0-9][0-9][0-9][-][0-9][0-9][0-9][0-9]"

- Anonymous February 22, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

find -name *.html | xargs grep "<\[+]{0,1}\d{1,2}\d{3}[-]\d{3}[-]\d{4}>/"

- Anonymous February 23, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

grep -l

- Z January 15, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

XSLT transformation

- lab October 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if its to be run at the prompt then it would be a perl script that holds the corresponding regular expression to check for phone no. formats.
(last option as HTML docs arent generally wellformed) if its a well-formed HTML document, I would use a small sax java program that would read entire html and go fetch that particular tag's data alone.
would it have any meta data tags to indicate phone no.s in them ?

- janedoe August 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

find . | xargs -I{} sh -c "grep  --with-filename --perl-regexp --regexp='\d\d\d(-)?\d\d\d(-)?\d\d\d\d' '{}' | head -n 1 | cut -f 1 -d':'"

- skwllsp September 20, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More