const solution = (operations) => {
const queue = [];
operations.forEach((exp) => {
const [command, number] = exp.split(" ");
if (command == "I") {
queue.push(parseInt(number));
queue.sort((a, b) => b - a);
return;
}
if (command == "D") {
if (number == "1") {
queue.shift();
} else {
queue.pop();
}
}
});
if (queue.length == 0) {
return [0, 0];
}
return [queue[0], queue[queue.length - 1]];
};