From f469b1c633d4dc39b138dd89ca5bba3112d168f3 Mon Sep 17 00:00:00 2001 From: YogeshPardeshi <31638743+YogeshPardeshi@users.noreply.github.com> Date: Sat, 23 May 2026 14:47:47 -0400 Subject: [PATCH 1/2] Create Problem1.java Problem1 --- Problem1.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Problem1.java diff --git a/Problem1.java b/Problem1.java new file mode 100644 index 0000000..93059d6 --- /dev/null +++ b/Problem1.java @@ -0,0 +1,49 @@ +class Problem1 { + int[][] dirs; + int m,n; + + public int orangesRotting(int[][] grid) { + this.dirs = new int[][]{{-1,0},{1,0},{0,1},{0,-1}}; + this.m = grid.length; + this.n = grid[0].length; + int fresh = 0; + + Queue q = new LinkedList<>(); + + for(int i=0; i=0 && c>=0 && r Date: Sat, 23 May 2026 14:48:28 -0400 Subject: [PATCH 2/2] Create Problem2.java Problem2 --- Problem2.java | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Problem2.java diff --git a/Problem2.java b/Problem2.java new file mode 100644 index 0000000..aab71e3 --- /dev/null +++ b/Problem2.java @@ -0,0 +1,39 @@ +/* +// Definition for Employee. +class Employee { + public int id; + public int importance; + public List subordinates; +}; +*/ + +class Problem2 { + HashMap map; + + public int getImportance(List employees, int id) { + this.map = new HashMap<>(); + + for(Employee emp: employees){ + map.put(emp.id, emp); + } + + Queue q = new LinkedList<>(); + q.add(id); + + int result = 0; + + while(!q.isEmpty()){ + int currId = q.poll(); + + Employee currObj = map.get(currId); + + result += currObj.importance; + + for(int subId : currObj.subordinates){ + q.add(subId); + } + } + + return result; + } +}