Fivetran SDE 2 Connectors interview question
Summary
During my interview for an SDE2 role at Fivetran, I was presented with a HackerRank coding challenge that involved optimizing car positions on a 2D plane to achieve a minimum fuel cost.
Full Experience
I participated in an interview round for the SDE2 position at Fivetran. The interview was conducted on the HackerRank platform, where I was given a specific coding problem to solve.
Interview Questions (1)
Given a 2D plane, we are given n cars and their position coordinates on the 2D plane in the form of an array.
I/P format: X[n] -> x-coordinates of n cars, Y[n] -> y coordinates of n cars
The objective of the problem is to bring all the cars on the same line parallel to the horizontal (x-axis) in 2D plane, with no gap between 2 cars. We are asked to achieve the objective with minimum fuel cost. The fuel cost for moving a car from (x1,y1) to (x2, y2) is abs(x1-x2) + abs(y1-y2)
Note: no gap between cars mean that if car1 is parked at (x1, y) then the next car should be parked at (x1+1, y)