-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e457ea7
commit 3a8689e
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
class Solution{ | ||
public: | ||
vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) { | ||
// code here | ||
int m = edges.size(); | ||
sort(disappear.begin(), disappear.end()); | ||
long long int dp[n + 1]; | ||
memset(dp, -1, sizeof(dp)); | ||
for (int i = 0; i < m; ++i) { | ||
int u = edges[i][0], v = edges[i][1]; | ||
if (dp[u] == -1 || dp[v] == -1 || dp[u] > dp[v]) | ||
dp[u] = dp[v] + 1; | ||
else | ||
dp[v] = dp[u] + 1; | ||
} | ||
|
||
vector<int> res(n); | ||
for (int i = 1; i <= n; ++i) { | ||
res[i - 1] = dp[i]; | ||
} | ||
return res; | ||
|
||
|
||
} | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class Solution { | ||
public: | ||
int findmax(vector<vector<int>>& grid,int row,int col){ | ||
int maxi=INT_MIN; | ||
for(int i=row;i<row+3;i++){ | ||
for(int j=col;j<col+3;j++){ | ||
maxi=max(maxi,grid[i][j]); | ||
} | ||
} | ||
return maxi; | ||
} | ||
vector<vector<int>> largestLocal(vector<vector<int>>& grid) { | ||
int n=grid.size(); | ||
vector<vector<int>>ans(n-2,vector<int>(n-2,0)); | ||
for(int i=0;i<n-2;i++){ | ||
for(int j=0;j<n-2;j++){ | ||
ans[i][j]=findmax(grid,i,j); | ||
} | ||
} | ||
return ans; | ||
} | ||
}; |
File renamed without changes.