Salesforce interview question Jan 2025

84
Jan 13, 2025
  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.
    For example, (5, 9) have the same parity, but (6,9) do not.
    Find the largest number that can be created. The swap operation can be applied any number of times.
Comments (0)