Amazon Interview Question for Software Engineer / Developers






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

www careercup.com/question?id=1552

- anonymous March 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

let the jigsaw be represent by a linked list of nodes, where each node is a piece in the puzzle. note that the head of the list is not necessarily the top left piece in the puzzle.
another thing: i am assuming that the pieces would be square with top, left, right and bottom as four sides.

struct node
{
node* next;
node* top;
node* bottom;
node* right;
node* left;
}

initially the list is connected by the next pointers. when the player arranges the pieces, the top, bottom, left and right can be assigned accordingly. They can be left as null if they are corner pieces.

to find the top left piece in the puzzle, iterate using the next node, until u reach a node that has both top and left as null.

- sp May 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

Why can't we simple consider a single or two dimensional array, where each slot holds a unique number?
In a situation when the jigsaw puzzle is solved, the array will be in a sorted manner.. For any move made, the value of two slots will be swapped..

Eg:
board[][] in unsolved condition:
5 7 3
6 9 4
2 8 1

play moves, a.k.a swap slots..
check if all are sorted or not, if not then puzzle isn't solved yet, if yes, then puzzle solved..

board[][] in ideal solved condition:
1 2 3
4 5 6
7 8 9

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

class Picture {
  List<Piece> Pieces;
  int noOfPiece;
  void Picture(){
       Pieces = new ArrayList<Pieces>(); 
  }

  void break(){
    for(int i=0;i<noOfPiece;i++){
	Pieces.add();
    }
    Collections.shuffle();
  }

   void merge(){
        //Todo Merging logic to be written
   }
}

class Pieces {
    int topNo,LeftNo,RightNo,BottomNo;
    void Pieces(int t,int l, int r, int b){
    	this.topNo=t;//
   }
}

class Game {
   Picture p = new Picture();
   p.beak();
   p.merge();
   
}

- Anonymous November 25, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class Picture {
  List<Piece> Pieces;
  int noOfPiece;
  void Picture(){
       Pieces = new ArrayList<Pieces>(); 
  }

  void break(){
    for(int i=0;i<noOfPiece;i++){
	Pieces.add();
    }
    Collections.shuffle();
  }

   void merge(){
        //Todo Merging logic to be written
   }
}

class Pieces {
    int topNo,LeftNo,RightNo,BottomNo;
    Piece left,right,top,button;
    void Pieces(int t,int l, int r, int b){
    	this.topNo=t;//
   }
}

class Game {
   Picture p = new Picture();
   p.beak();
   p.merge();
   
}

- shah.sunil435 November 25, 2017 | 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