USA | Verily Life Sciences | Onsite Problem
Summary
I completed an onsite interview with Verily Life Sciences in USA, where I was presented with an interesting algorithmic problem about doubling and inverting array transformations. I found the first part straightforward but encountered difficulties and a bug in my implementation for the second part, although I was told I was very close to the solution.
Full Experience
Completed an onsite for Verily pretty recently and got asked this pretty interesting problem in one of the rounds.
Fun with Doubles
Part 1
Given an array arr of integers, double each element and concatenate.
For example, [1, 2, 4] --> [1, 2, 4, 2, 4, 8]
notice the pattern in the output?
Part 2
Given an output that may or may not come from part 1, identify the inverse.
[1, 2, 4, 2, 4, 8] --> [1, 2, 4]
[4, 2, 8, 16] --> [2, 8]
[1, 4] --> NO INVERSE
Reflection
- Part 1 as you may expect is very straightforward. spend at most 5 minutes on coding it up
- I sort of got stuck on the thought process for part 2. I think I had the idea of "pairing things up", but I had a tricky bug in my implementation
- In hindsight, I realized that the implementation was really straightforward and I sort of overcomplicated it. Interviewer said that "I was pretty close and with minor updates, I would have gotten it"
- 50/50 on if I'll move forward
Interview Questions (2)
Double and Concatenate Array Elements
Given an array arr of integers, double each element and concatenate.
For example, [1, 2, 4] --> [1, 2, 4, 2, 4, 8]
notice the pattern in the output?
Inverse of Double and Concatenate Array
Given an output that may or may not come from part 1, identify the inverse.
[1, 2, 4, 2, 4, 8] --> [1, 2, 4]
[4, 2, 8, 16] --> [2, 8]
[1, 4] --> NO INVERSE