Google Interview Question for Software Engineer / Developers






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

Looks like a problem of Finite Automata. The test pattern needs to be converted into f.*l.*t.*_.*f.*l.* Try to match the given string on this pattern.

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

Build a trie and if path does not lie on any end-string then flag it as non-present.

- Ashish Kaila August 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

could you please explains question clearly?

- Anonymous August 31, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey34921" class="run-this">Build a hash map for the file with keys as individual characters and values as list of positions.
current_position = 0
Read the input string.
look up for the character n hash table
if not present
return false
else
if any position in list is greater than current_position
set current_position to position found in hash map
continue
else
return false

return true</pre><pre title="CodeMonkey34921" input="yes">
</pre>

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

question is not clear. Please clearly specify the input and output

- learner October 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bytestorm's idea is correct. However there's no need to implement full Finite Automata due to the nature of this problem. Simply search for each character of pattern in the given filename and return true only if pattern can be exhausted.

Code in Java:

String filename = ...
String pattern = ...

int p1 = 0, p2 = 0;

while(p1 >= 0 && p2 < pattern.length){
   char c = pattern.charAt(p2);
   int tmp = filename.indexOf(c, p1);
   if(tmp < 0){
      return false;
   }
   p1 = tmp + 1;
   p2 ++;
}

return true;

- futurnist April 21, 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