Green Bricks Interview Questions
- 0of 0 votes
AnswerGreen Bricks asked this question for the post of project leader for their upcoming project.
- John May 31, 2012 in United States for 1 alpha
project engineer has to be in java.
green bricks also offered attractive salary.
the problem was as follows:
Given a set of figures and a board (a 2D array), you are required to figure out if all the figures can be placed on the board such that no two figures overlap each other. A figure can be of any shape and is represented using a matrix of 0s and 1s. The 1s in the matrix indicate the solid part that makes the figure.
Note:
Overlapping of 0s of figure A with 1s and 0s of figure B is allowed.
The figures provided are to be fitted as is without any rotation.
There is only one figure per matrix.
The matrix describing the figure will not have any empty row or column.
Input specification:
The first line contains two integers M and N (0<=50 and 0<=50), the dimensions of the board. The board is empty at the start.
The second line contains an integer F (0<=F<=10), indicating the number of figures followed by F figures.
Each figure has two integers R and C, the dimensions of the matrix containing the figure followed by R lines containing C integers 0's or 1's separated by a space.
Output specification:
If all the given figures fit onto the board then print YES followed by the number of empty cells on the board, separated by a space. If all the pieces cannot be fitted on the board together then print NO.
Sample Input and Output:
Input:
4 4
3
1 1
1
4 3
0 0 1
1 1 1
0 0 1
0 1 1
4 3
1 1 1
1 0 0
1 1 1
1 0 0
Output:
YES 0
this was the sample input output case.
you have to make the program for this which should also work on the following test cases.
Test Case 1:
4 4
3
1 1
1
4 3
0 0 1
1 1 1
0 0 1
0 1 1
4 3
1 1 1
1 0 0
1 1 1
1 0 0
Test Case 2:
4 4
2
4 4
0 0 0 1
0 0 1 0
0 1 0 0
1 0 0 0
4 4
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
Test Case 3:
8 8
8
2 2
1 1
1 1
2 2
1 1
1 1
2 2
1 1
1 1
2 2
1 1
1 1
2 2
1 1
1 1
2 4
1 1 1 1
1 1 1 1
4 4
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
4 8
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 0 0 0 0 0 0
1 1 0 0 0 0 0 0
you have to figure out the answers.
regards,
john| Report Duplicate | Flag | PURGE
Green Bricks Software Engineer / Developer Java - 0of 0 votes
AnswersA newly established university in New York has its campus located in a remote corner of the city. The university offers several courses and students are required to take a certain number of these courses. Each course publishes its schedule of lectures on a day-wise basis, i.e., it publishes the days of the week on which it holds lectures. Each course chooses exactly three days of the week for lectures. Travelling to the university is a nuisance and all the students who attend courses there, seek to minimise the number of days that they should have to travel. Given each course's schedule, you have to help the students decide on a combination of courses, such that they minimise the number of days that they have to travel to the university.
- Anonymous May 30, 2012 in United States for test alpha
The university has strict attendance norms and it insists that students should attend all the lectures that their respective course offers.
Assume that the number of courses required will never be greater than the number of courses offered. In addition, there will be a unique combination of days, which allows the students to take the required number of courses and minimise travel.
Input specification:
First line will contain total number of courses (T) and the number of courses you are required to register (R) for.
The next T lines will each contain name of the course and those days on which the lectures for the course are held. The first word on each line is the name of the course and the rest of the words are three-letter words signifying the days of the week. E.g., "Physics MON WED FRI".
Output specification:
You should output the names of the days on which the student is required to go to the University to attend lectures. These should be printed on a single line in sorted order (SUN to SAT) with a single whitespace as a separator. Terminate the output with a newline.
Sample Input and Output:
Input:
6 3
Physics MON WED TUE
Chemistry TUE WED THU
Biology WED SAT THU
Economics MON FRI WED
English TUE WED FRI
History MON THU FRI
Output:
MON TUE WED FRI
Input:
6 2
Physics SUN TUE WED
Chemistry TUE WED THU
Biology THU WED FRI
Economics MON WED FRI
English THU TUE WED
History FRI MON THU
Output:
TUE WED THU| Report Duplicate | Flag | PURGE
Green Bricks Software Engineer / Developer Java