Amazon Interview Report
- 0of 0 votes
Answersencode binary in bytes is to give a matrix of size M * N,
- ajay.raj March 05, 2018 in United States
This matrix is encoded in bytes as a 4 * 4 bool matrix
[0 0 0 0
1 0 0 1
0 0 0 0
0 0 0 1]
Will be encoded as a byte array [9, 1].
Then write a function set_one (vector <byte> arr, int M, int N, int start_row, int start_col, int end_row, int end_col);
Set all of 0 from (start_row, start_col) to (end_row, end_col) to 1
for example
start_row = 1
start_col = 2
end_row = 2
end_col = 0,
Just that 4 * 4matrix will become
[0 0 0 0
1 0 1 1
1 0 0 0
0 0 0 1]
The byte array after encode should be rewritten as [11, 129].| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answersfind out all of the state machine will guaranteed to come to safe state
- ajay.raj March 05, 2018 in United States
ex
A -> [B, C, D, E]
B -> [A]
C -> [D, E]
D -> [E].
E -> [safe state]
Output [C, D, E] because once these states will eventually go to safe state| Report Duplicate | Flag | PURGE
Amazon SDE1