Amazon OA
Anonymous User
2348
Got below question in Amazon OA: 

Amazon recently launched a new game Fruit Crush. In this game you are alllowed to choose two dissimilar fruits and crush them. 
Each type of fruit is represented as an integer in the array. Formally, you can choose any two unequal integers in the array and delete them. 
Given an array of fruits of size n, return the minimum possible number of fruits left after the given operation is performed any number of times.

Example: 
int[] fruits = {3,3,1,1,2} is 1. 

Fruits 1 (banana) and 2 (pineapple) can be crushed first followed by numbers 1 (banana) and 3 (orange). Only 3 (orange) remains in the array. hence the answer is 1
Comments (16)