Fivetran SDE 2 Connectors interview question

fivetran logo
fivetran
SDE II
June 10, 20233 reads

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)

Q1
Minimize Fuel Cost to Align Cars on a Line
Data Structures & Algorithms

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)

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!