Fruit Crush
Problem Overview
- Given an array of integers representing fruit types, you can repeatedly delete any two unequal values; return the minimum number of fruits left.
- Input: fruits array of size n; Output: an int with the minimum remaining; Constraints: 1 ≤ n ≤ 1e5, 1 ≤ fruits[i] ≤ 1e9.
- Real-world context: Amazon’s Fruit Crush game where dissimilar fruits can be crushed together.
- Asked in Amazon interviews; a classic coding interview problem and interview question on arrays.
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:
