Title : SDE - I
Reorder Data Log Files but slightly different. - Used a custom comparator to solve this.
LC Problem : https://leetcode.com/problems/reorder-data-in-log-files/
Prompt given below, solved in O(M * N) Complexity
/* Give a computer with total K memory space, and an array of foreground tasks and background tasks
the computer needs to do. Write an algorithm to find a pair of tasks such which give the most optimal memory usage, Here the most optimal indicates the maximum memory usage. If the deviceCapacity is 10MB and there exists a pair with 9MB then that is most optimal pair if there exists no other pair with 10MB usage
/*
**Input **
DeviceCapacity, an integer representing the maximum capacity of the given device;
ForegroundAppList, a list of pairs of integers where the first integer represents the unique ID of a foreground application and the second integer represents the amount of memory required by this application.
BackgroundAppList, a list of pairs of integers where the first integer represents the unique ID of a foreground application and the second integer represents the amount of memory required by this application.
**Example:**
Example 1:
deviceCapacity = 7
foregroundAppLIst = [[1,2], [2,4], [3,6]]
backgroundAppList = [[1,2]]
Output: [[2,1]]
*/Solved All Questions and test cases waiting for result