Yahoo Interview Question for Software Engineer / Developers






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

what can be done here is that we need to maintain a stack.at every turn we need to create an object that stores the possible turns that can be taken at that point and also marks which turn we have selected and push that object onto the stack.also at every move forward we need to push move to stack.at a dead end turn around with two right turns and move forward with every pop of move object.as soon as we encounter a turn object,we need to analyse it and start moving it the direction not taken by us before and mark that direction also as taken. continue this until u find a cheeze .
if anyone has beter idea then do post it here and do comment on the idea suggested.

- saumils1987 September 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

yup correct , basically its backtracking ..

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

boolean findCheese(Point start)
	 {
		 if(isCheese())
		 {
			 eatCheese();
			 return true;
		 }
		 else if(isWall())
		 {
			 return false;
		 }
		 return findCheese(p.moveForward()) || findCheese(p.turnRight()) ||           findCheese(p.turnLeft());
	 }

- gullu October 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

wrong!!

- ya thats me! September 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void findCheese(){
if(isCheese()){
eatCheese();
exit;
}
turnRight();
while(isWall()){
turnLeft();
}
moveForward();
findCheese();
}

These is basically having the mouse follow the wall, by always having it on its right side.

- Guadalupe October 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <bits/stdc++.h>

using namespace std;

bool isPoss(int arr[8][8],vector<vector<int>> &v,int i, int j){
    cout<<i<<" "<<j<<endl;
    if(arr[i][j]==0)
        return false;
    if(i<0 || i>=8 || j<0 || j>8)
        return false;
    if(arr[i][j]==9)
        return true;
    if(v[i][j]==0){
        v[i][j]=1;
        return isPoss(arr,v,i+1,j)||isPoss(arr,v,i,j+1)||isPoss(arr,v,i-1,j)||isPoss(arr,v,i,j-1);        
    }
    return false;
}

int main()
{
   int arr[8][8];
   for(int i=0;i<8;i++){
       for(int j=0;j<8;j++){
           cin>>arr[i][j];
       }
   }
   
   vector<vector<int>> v(8,vector<int>(8,0));
   cout<<isPoss(arr,v,0,0);
   
   return 0;
}

- Anonymous July 05, 2021 | 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