Company: Barclays
Difficulty: medium
Minimum Possible Length The task is to calculate the minimum possible length of cable required to connect a starting retailer to a head retailer through a series of intermediate retailers. The retailers are positioned along the X-axis, and the head retailer is located at a specific coordinate. Input Format An integer posK , representing the position of the starting retailer. A list retailerXCord of integers, representing the X-coordinates of the retailers. An integer headXCord , representing the X-coordinate of the head retailer. An integer headYCord , representing the Y-coordinate of the head retailer. Output Format Return a double representing the minimum possible length of cable required. Constraints 1 ≤ posK ≤ 10 5 1 ≤ retailerXCord[i] ≤ 10 5 1 ≤ headXCord , headYCord ≤ 10 5 Example Input: posK = 2 retailerXCord = [1, 3, 5] headXCord = 6 headYCord = 8 Output: 10.0 The minimum cable length is calculated based on the positions of the retailers and the head retailer. Code Template //