Adobe Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

While enumerating the matrix through a nested for loop , doubly linked lists can be maintained to represent the rows and columns which would be very easy to reverse.

So basically all possible words can be found in n^2 complexity

Let me know if this is correct , I would want to actually code it , if this is the right direction.

- Anonymous September 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

How can you find all words in n^2??

- ginmatrix September 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

you can't get all the words with this approach unless i am unable to understand your approach. Could you give little bit of detail

- Bruce October 15, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think this could be done. While you should also have diagonal pointers.

So, in effect there should be 8 pointers for all ajoining cells. giving the complexty of (4n)^2

- Mike November 09, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I assume its something like a[4][4] = { a,e,i,j | c,d,o,k | l,m,n,p | q,s,t,u }. Now traverse the matrix in n2 - [a|ae|aei|aeij|ac|acl|aclq]and so on ... for each word search in dictionary maintained in trie in O(k)

- Amit September 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think there is no need to check all of them. Suppose if we have q m c k p d ... When we search the dictionary if we have any words starting with "qm" we will know that there are no words starting with that so we can skip that sequence completely. This way we can save more time.

Also, you need to ask the interviewer whether you can reconsider a letter. I mean if you have c, a, n should we consider it as two words can, an?

- Vijay September 20, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

here flood fill algorithm can be used.for every call of that function we have to check that the word formed till now is present in the dictionary or not.

- geeks September 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

similar thing : question id=10506747

- Psycho September 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

looks different to me. the 10506747 question seems to be limiting the size of the matrix. In that case, its easy to simply enumerate all the words . In this question, you really have to be smart about the datastructure you choose

- JayUnit100 September 26, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

You can choose any size of the matrix. Its should be the input. So, there is no limit in the size!

- Psycho September 26, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
using namespace std;
int main()
{char a[10][10];
char s[20];
cout<<"eneter the matrix character of 5 by 5 matrix\n";
for(int i=0;i<5;i++)
for(int j=0;j<5;j++)
cin>>a[i][j];
cout<<"enter the char string which we want to find of length 3.....\n";
for(int i=0;i<3;i++)
cin>>s[i];
int k=0;
for(int i=0;i<5;i++)
for(int j=0;j<5;j++)
{ int count=0;
if(a[i][j]==s[k])
{ count++;
if(a[i][j+1]==s[k+1])
{ while(count!=3&&j<5)
{ if(a[i][j+1]==s[k+1])
{ count++; j++;k++;}
else
{ count=1;}
}
if(count==3)
{ cout<<"string is present\n"; break;}
}
else if(a[i][j-1]==s[k+1])
{ while(count!=3&&j>=0)
{ if(a[i][j-1]==s[k+1])
{ count++;j--;k++;}
else
{ count=1; break;}
}
if(count==3)
{ cout<<"string is present \n";break;}
}
else if(a[i+1][j]==s[k+1])
{ while(count!=3&&i<5)
{ if(a[i+1][j]==s[k+1])
{ count++; i++;k++;}
else
{ count=1; break;}
}
if(count==3)
{ cout<<"string is present\n";break;}
}
else if(a[i-1][j]==s[k+1])
{ while(count!=3&&i>=0)
{ if(a[i-1][j]==s[k+1])
{ count++;i--;k++;}
else
{ count=1; break;}
}
if(count==3)
{cout<<"string is present \n"; break;}
}
else if(a[i+1][j+1]==s[k+1])
{ while(count!=3&&i<5&&j<5)
{ if(a[i+1][j+1]==s[k+1])
{ count++;i++;j++;k++;}
else
{count=1; break;}
}
if(count==3)
{ cout<<"string is present\n";
break;}
}
else if(a[i-1][j+1]==s[k+1])
{ while(count!=3&&i>=0&&j<5)
{ if(a[i-1][j+1]==s[k+1])
{ count++;i--;j++;k++;}
else
{count=1;break;}
}
if(count==3)
{ cout<<"string is present\n";
break;}
}
else if(a[i+1][j-1]==s[k+1])
{ while(count!=3&&i<5&&j>=0)
{ if(a[i+1][j-1]==s[k+1])
{ count++;i++;j--;k++;}
else
{ count=1;break;}
}
if(count==3)
{ cout<<"string is present\n";
break;}
}
else if(a[i-1][j-1]==s[k+1])
{ while(count!=3&&i>=0&&j>=0)
{ if(a[i-1][j-1]==s[k+1])
{ count++;i--;j--;k++;}
else
{ count=1; break;}
}
if(count==3)
{ cout<<"string is present\n";
break;}
}
}
}

system("pause");
return 0;
}

- Mukesh Kumar Dhaker October 01, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can it done in O(n^3)?

- gautam October 06, 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