From 8615d1b2db6c2aef721a9fc400046e73c2c60693 Mon Sep 17 00:00:00 2001 From: SUJAY GIJRE Date: Sun, 8 Feb 2026 15:55:54 -0500 Subject: [PATCH 1/2] Create RottingOranges.cpp --- RottingOranges.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 RottingOranges.cpp diff --git a/RottingOranges.cpp b/RottingOranges.cpp new file mode 100644 index 0000000..efe0c07 --- /dev/null +++ b/RottingOranges.cpp @@ -0,0 +1,62 @@ +class Solution { +public: + vector> dirs = {{1,0}, {-1,0}, {0,1}, {0,-1}}; + int orangesRotting(vector>& grid) { + queue> q; + unordered_set us, freshO; + + auto key = [&](int x, int y) { + return to_string(x)+"+"+to_string(y); + }; + + auto markVisited = [&](int x, int y) { + string str = key(x, y); + us.insert(str); + freshO.erase(str); + }; + + auto isSafe = [&](int x, int y) { + if (x >= 0 && y >= 0 && x < grid.size() && y Date: Sun, 8 Feb 2026 15:56:22 -0500 Subject: [PATCH 2/2] Create EmployeeImportance.cpp --- EmployeeImportance.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 EmployeeImportance.cpp diff --git a/EmployeeImportance.cpp b/EmployeeImportance.cpp new file mode 100644 index 0000000..acd4e47 --- /dev/null +++ b/EmployeeImportance.cpp @@ -0,0 +1,39 @@ +/* +// Definition for Employee. +class Employee { +public: + int id; + int importance; + vector subordinates; +}; +*/ + +class Solution { +public: + int getImportance(vector employees, int id) { + unordered_map> idsMap; + unordered_map usEmp; + vector inorder; + for (int i=0;iid] = employees[i]->subordinates; + usEmp[employees[i]->id] = employees[i]; + } + + queue q; + q.push(id); + int answer = usEmp[id]->importance; + + while (!q.empty()) { + auto node = q.front(); + q.pop(); + + vector direct = idsMap[node]; + for (int i=0;iimportance; + q.push(direct[i]); + } + } + + return answer; + } +};