You are working on an Amazon Data Center where you are required to reduce the amount of main memory consumption by the processes.
Given list of processes where each value representing memory consumption by the processes and given one variable m representing number of processes to be removed. We need to delete m number of processes from the list in contiguous manner and return minimum amount of main memory used by all the processes running after deleting contiguous segment of processes.
Complete the function reduceMemoryUsage in the editor.
reduceMemoryUsage has the following parameters:
int[] processes: an array of integers representing memory consumption by the processesint m: the number of processes to be removed
Returns
int: the minimum amount of main memory used after deleting a contiguous segment of processes
processes = [10, 4, 8, 13, 20] m = 2 return = 22
Removing 13 and 20 as they are consuming large memory. The remaining processes consume 10 + 4 + 8 = 22 units of memory, which is the minimum possible.
1 < N < 1000000000//size of the array1 < m < 100000//contiguous segment of the array.1 < process[i] < 1000000000
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
public int reduceMemoryUsage(int[] processes, int m) {
// write your code here
}