- Arrays, deque, Greedy, Sorting

Minimum number of deques required to make the array sorted

#include using namespace std;int minDeques(vector arr){            vector fronts, backs;        for (int i = 0; i < arr.size(); i++) {                        bool hasBeenPushed = false;        for (int j = 0; j < fronts.size(); j++) {                                    if (arr[i] < fronts[j]) {                bool isSafe = true;                for (int k = 0; k < arr.size(); k++) {                    if (arr[i] < arr[k]                        && arr[k] < fronts[j]) {                        isSafe = false;                        break;                    }                }                                                if (isSafe) {                    fronts[j] = arr[i];                    hasBeenPushed = true;                    break;                }            }                                    if (arr[i] > backs[j]) {                bool isSafe = true;                for (int k = 0; k < arr.size(); k++) {                    if (arr[i] > arr[k]                        && arr[k] > backs[j]) {                        isSafe = false;                        break;                    }                }                                                if (isSafe) {                    backs[j] = arr[i];                    hasBeenPushed = true;                    break;                }            }        }                                if (!hasBeenPushed) {            fronts.push_back(arr[i]);            backs.push_back(arr[i]);        }    }    return fronts.size();}int main(){    vector arr = { 3, 6, 0, 9, 5, 4 };    cout