Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You want to park your bicycle in a bicycle parking area where bike racks are aligned in a row. There are already N bikes parked

You want to park your bicycle in a bicycle parking area where bike racks are aligned in a row. There are already N bikes parked there(each bike is attached to exactly one rack, but a rack can have multiple bikes attached to it). We call racks that already have bikes attached used. You want to park your bike in a rack in the parking area according to the following criteria: the chosen rack must lie between te first and the last used racks(inclusive); the distance between the chose rack and any other used rack is as big as possible. A description of the bikes already parked in the racks is given in a non-empty zero-indexed array A: element A[K] denotes the postion of the rack to which bike number K is attaced (for 0 <= K < N). The central position in the parking area is position 0. A positive value means that the rack is located A[K] meters to the right of the cetral position 0; a negative value means that it's located |A[K]| meters to the left. That, given a non-empty zero-indexed array A of N integers, returns the largest possible distance in meters between the chosen rack and any other used rack. Assume that: N is an integer within the range [2..100,000]; each element of array A is an integer within the range [-1,000,000,000..1,000,000,000].

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions