Question bank › Two Pointers
Dsa Two Pointers Medium

Pharmacy Delivery

You’re tasked with optimizing pharmacy deliveries in a small town. Given an array representing the distances of customers from the pharmacy, determine the minimum total distance for the delivery of medicines to all customers. Note that each delivery can cover two customers at a time from opposite ends of the array. Input: - The first line contains a single integer N (1 ≤ N ≤ 1000), the number of customers. - The second line contains N space-separated integers representing the distances from the pharmacy. Output: - Print the minimum total distance for the deliveries. Example: Input: 5 1 2 3 4 5 Output: 9

Key concepts

two_pointersdistance_calculation

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.