Optimal Utilization
You are given a device with a limited amount of memory. Each device must run two applications at the same time: one foreground application and one background application. Each application is identified by a unique integer ID (unique within its type), requires a fixed non-zero amount of memory to execute, and is classified as either foreground or background.
A pair of applications (one foreground and one background) is considered optimal if:
Your task is to write an algorithm that finds all pairs of foreground and background applications that optimally utilize the device memory.
The function should return a list of pairs [foregroundAppID, backgroundAppID] representing the IDs of applications that optimally utilize the device. If no valid pair exists, return a list with an empty pair.
Input Format
deviceCapacity representing the device's memory.Output Format
[foregroundAppID, backgroundAppID] for each optimal application pair.