Ice Cream Sticks
Problem Overview
- Given N ice cream stick heights and integer K, change each height by +K or -K exactly once and find the minimum possible difference between tallest and shortest.
- Input: K, N, and array A of heights; Output: the minimum difference between shortest and tallest after all sticks are modified; Constraints: 0<K<=30, 0<N<=30, 0<=A[i]<=500.
- Real-world context: standardizing stick sizes for consistent packaging/manufacturing.
- This coding interview problem is an interview question from Intuit interviews.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
