Generation

generate functionTue, 03 Jan 2023

Given an array of positive integers, truncate it such that `2×min` becomes more than `max`, and the total number of removals is minimal. The `min` and `max` are the minimum and the maximum elements in the array, respectively. The elements can be removed either from the start or end of the array if the above condition does not meet. public static int truncate(List<Integer> nums){

/* input: [4, 5, 100, 9, 10, 11, 12, 15, 200] output: 4 input: [4, 7, 5, 6] output: 0 input: [20, 7, 5, 6] output: 1 */

Questions about programming?Chat with your personal AI assistant