Pergunta de entrevista da empresa Rail Vision (Israel)

The technical interview: 1. I was shown a C++ small class `A` which had a pointer field, a constructor which initializes the pointer with a new allocation and a destructor that just deletes the pointer (default copy and move constructors and assignments operators). I was then given a small main function which allocated a variable of `A` on the stack and was asked to write code which used that class and would have caused a crash if it had ran in a Linux environment. 2. I was asked to design and implement a small component which receives sensors data as input, then needs to call some external algorithm, giving it the sensors data as input. The amount of sensors `N` was known in advance. Each sensor has a different frequency for taking a measurement. I was allowed to discard measurements if I had deemed that valuable or necessary. During the discussion, the interviewer added that the sensors data the component stores needs to be moved from the component to the algorithm. The non-technical interview: 1. Whether or not it would be comfortable for me to commute to the work place. 2. How long (roughly) I plan to stay at the company.

Resposta da entrevista

Sigiloso

16 de jan. de 2023

For the technical interview: 1. The key is to delete the pointer 2 times. Equivalently, call the destructor 2 times. 1 time already happens by the main function at the end of its scope. The other time can be achieved by calling a function which receives `A a` as an argument and then calling it with the aforementioned variable (note that the copy constructor will be called). 2. I decided to use the last seen measurements from each sensor and once I had received a measurement (at least 1) from each sensor, I would call the algorithm. To do that, I had implemented a class with the amount of sensors I had received data from and an array storing the sensors measurements and whether a measurement had been received from that sensor. Then, when the amount of sensors received from equals to `N`, I called the algorithm, moving (std::move) the sensors measurements to the algorithm arguments container and then reset the other variables of that class.