## Honeywell Interview Question for SDE-2s

Country: United States
Interview Type: Written Test

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

Is there a typo? What's an arrow?? Do you mean area??? Please clarify

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

The space

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

``````0,0,0,0,0,0,0
0,0,1,1,1,0,0
0,0,1,0,1,0,0
0,0,1,0,1,0,0
0,1,0,0,0,1,0
0,0,1,0,1,0,0
0,0,0,1,0,0,0``````

Assuming the area is always bounded, it does not matter what shape it is.
* You can traverse the matrix row-by-row, look for first 1(forward traversal on row), and last 1(backward traversal on same row).
* Then you start filling all the elements in between these 2 indexes.
* If you want to make it work for complex shapes, then you can maintain a state whether you are inside the shape or outside.
For example:

``````0,0,0,0,0,0,1,1,1,1,0,0,0,0
0,0,1,0,0,0,1,0,0,1,0,0,0,0
0,1,0,1,1,1,1,0,0,1,0,0,0,0
0,1,0,0,0,0,0,0,0,1,0,0,0,0
0,0,1,0,0,0,1,0,0,1,0,0,0,0
0,0,0,1,0,1,0,1,0,1,0,0,0,0
0,0,0,0,1,0,0,0,1,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0``````

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

``````0,0,0,0,0,0,1,1,1,1,0,0,0,0
0,0,1,0,0,0,1,0,0,1,0,0,0,0
0,1,0,1,1,1,1,0,0,1,0,0,0,0
0,1,0,0,0,0,0,0,0,1,0,0,0,0
0,0,1,0,0,0,1,0,0,1,0,0,0,0
0,0,0,1,0,1,0,1,0,1,0,0,0,0
0,0,0,0,1,0,0,0,1,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0``````

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

``````0,0,0,0,0,0,1,1,1,1,0,0,0,0
0,0,1,0,0,0,1,0,0,1,0,0,0,0
0,1,0,1,1,1,1,0,0,1,0,0,0,0
0,1,0,0,0,0,0,0,0,1,0,0,0,0
0,0,1,0,0,0,1,0,0,1,0,0,0,0
0,0,0,1,0,1,0,1,0,1,0,0,0,0
0,0,0,0,1,0,0,0,1,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0``````

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

Output

``````0 0 0 0 0 0 0
0 0 1 1 1 0 0
0 0 1 0 1 0 0
0 0 1 0 1 0 0
0 1 0 0 0 1 0
0 0 1 0 1 0 0
0 0 0 1 0 0 0

0 0 0 0 0 0 0
0 0 1 1 1 0 0
0 0 1 1 1 0 0
0 0 1 1 1 0 0
0 1 1 1 1 1 0
0 0 1 1 1 0 0
0 0 0 1 0 0 0``````

Code(does not work for complex shapes)

``````#include <stdio.h>

typedef unsigned int uint32_t;

void print(int *arr, uint32_t rows, uint32_t cols) {
for (uint32_t i = 0; i < rows; ++ i) {
for (uint32_t j = 0; j < cols; ++ j) {
printf("%d ", arr[i * cols + j]);
}
printf("\n");
}
}

void fillObjects(int *arr, uint32_t rows, uint32_t cols)
{
for (uint32_t i = 0; i < rows; ++ i) {
uint32_t j = 0;

// left boundary
while (j < cols && arr[i* cols + j] != 1) ++ j;
uint32_t left = j;
j = cols - 1;

// right boundary
while (j > left && arr[i*cols + j] != 1) -- j;
uint32_t right = j;

// fill between maintaining state whether or
// not to fill
++ left;
while (left < right) {
arr[i * cols + left] = 1;
++ left;
}
}
}

int main() {
int arr[7*7] = {
0,0,0,0,0,0,0,
0,0,1,1,1,0,0,
0,0,1,0,1,0,0,
0,0,1,0,1,0,0,
0,1,0,0,0,1,0,
0,0,1,0,1,0,0,
0,0,0,1,0,0,0};
print(arr, 7, 7);
printf("\n");
fillObjects(arr, 7, 7);
print(arr, 7, 7);
/*
int arr2[14*9] = {
0,0,0,0,0,0,1,1,1,1,0,0,0,0,
0,0,1,0,0,0,1,0,0,1,0,0,0,0,
0,1,0,1,1,1,1,0,0,1,0,0,0,0,
0,1,0,0,0,0,0,0,0,1,0,0,0,0,
0,0,1,0,0,0,1,0,0,1,0,0,0,0,
0,0,0,1,0,1,0,1,0,1,0,0,0,0,
0,0,0,0,1,0,0,0,1,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0
};

print(arr2, 9, 14);
printf("\n");
fillObjects(arr2, 9,14);
print(arr2,9,14);
*/

return 0;
}``````

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.

### 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.