Member-only story
PySpark: Interview Questions (Coding) — Part 2
Journey through Interview Scenarios
Hi, Welcome to the next instalment of my exploration into PySpark scenario-based interview questions!
In case if you have missed my previous part — part -1
In this segment, I’ll continue to provide another set of interview questions and important questions from interview point of view along with code solutions.
Let’s dive in —
Q1. Cheapest and Fastest Flight
Find the cheapest and fastest airline for each travel date and mark the flights accordingly, ‘Yes’ for the flights which are cheapest or fastest and with ‘No’ for rest of the airline
Given Input —
airline| date| travel_duration| price
+ — — — -+ — — — -+ — — — — — — -+ — — — -+
indigo| 21/03/2024| 1:10| 5000
airindia| 21/03/2024| 2:00| 3500
delta| 21/03/2024| 2:00| 2000
indigo| 22/03/2024| 1:10| 5000
delta| 22/03/2024| 2:15| 1500
vistara| 22/03/2024| 1:00| 6000Output —
+ — — — — + — — — — — + — — — — — — — -+ — — -+ — — — — + — — — — +
| airline| date|travel_duration|price|cheapest|fastest|
+ — — — — + — — — — — + — — — — — — — -+ — — -+ — — — — + — — — — +
|indigo|21/03/2024| 1:10| 5000| No| Yes|
|airindia|21/03/2024| 2:00| 3500| No| No|
|…
