From 05a858a8fd9acfe5edfc8aaf8bfedf93758d9c7d Mon Sep 17 00:00:00 2001 From: Dharmik Date: Thu, 16 Apr 2026 22:58:04 -0400 Subject: [PATCH 1/2] problem solved --- .DS_Store | Bin 0 -> 6148 bytes Employee.java | 34 ++++++++++++++++++++++++++++++++++ RottenOrange.java | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 .DS_Store create mode 100644 Employee.java create mode 100644 RottenOrange.java diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1d2c087a50fa04d28d8c742ad18aa34e99a4a114 GIT binary patch literal 6148 zcmeHKF-`+P474Fd5KT(TeE||bSfWdT1Py!ug_J?5=&#}{e1o4QGq#0@E=V*qXe@bW z*X!B6o8o*nGhe=KZp;>DHir}Kox{|)PoLOXMH~pn84tFyYkRfL-FA|FIzaA)J%V>@ z!*~AfWxd_4vCBvMzy subordinates; +}; +TC: O(n) whre n is the number of employees +SC: O(n) for the map and the recursive stack +*/ + + + +class Solution { + Map map; + int sum; + public int getImportance(List employees, int id) { + map = new HashMap<>(); + sum = 0; + for(Employee e: employees){ + map.put(e.id, e); + } + dfs(id); + return sum; + } + + private void dfs(int id){ + Employee e = map.get(id); + sum = sum + e.importance; + for(int eid: e.subordinates){ + dfs(eid); + } + } +} \ No newline at end of file diff --git a/RottenOrange.java b/RottenOrange.java new file mode 100644 index 0000000..0efb13d --- /dev/null +++ b/RottenOrange.java @@ -0,0 +1,36 @@ + +/* +Tc: O(m *n) +SC: O(m * n) +m = number of rows and n is number of columns +class Solution { + public int orangesRotting(int[][] grid) { + if(grid.length == 0 || grid[0].length==0){ + return 0; + } + int m = grid.length; + int n = grid[0].length; + Queue q = new LinkedList<>(); + int count = 0; + int level = 0; + int[][] dirs = {{-1,0},{1,0},{0,1},{0,-1}}; + + for(int i = 0; i < m; i++){ + for(int j = 0; j < n; j++){ + if(grid[i][j]== 1){ + count++; + } + else if(grid[i][j] == 2){ + q.add(new int[]{i,j}); + } + } + } + while(!q.isEmpty()){ + int size = q.size(); + for(int i = 0; i < size; i++){ + + } + } + + } +} \ No newline at end of file From 90d59a110ff322edc6e8cbe6508f9175663e39ee Mon Sep 17 00:00:00 2001 From: Dharmik Harkhani <59807706+harkhanid@users.noreply.github.com> Date: Thu, 16 Apr 2026 22:59:39 -0400 Subject: [PATCH 2/2] Delete .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 1d2c087a50fa04d28d8c742ad18aa34e99a4a114..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKF-`+P474Fd5KT(TeE||bSfWdT1Py!ug_J?5=&#}{e1o4QGq#0@E=V*qXe@bW z*X!B6o8o*nGhe=KZp;>DHir}Kox{|)PoLOXMH~pn84tFyYkRfL-FA|FIzaA)J%V>@ z!*~AfWxd_4vCBvMzy