Salesforce interview question Jan 2025

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-01-13Added By Anonymous
Source: Link
1.You have n chocolates with weights given in an array weights[n], where weights[i] represents the weight of the ith chocolate. Each day, you can pick one chocolate, consume half of its weight (calculated as floor(weights[i] / 2)), and keep the remaining portion. Calculate the minimum possible total weight of the chocolates after d days. Note that you can eat from the same chocolate multiple times.
2.Given a number num, two adjacent digits can be swapped if their parity is the same, that is, both are odd or both are even.
3.For example, (5, 9) have the same parity, but (6,9) do not.
4.Find the largest number that can be created. The swap operation can be applied any number of times
Comments