Skip to content

Commit

Permalink
new commits
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitiz11101 committed May 12, 2024
1 parent e457ea7 commit 3a8689e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Graphs/lc.cpp
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.
22 changes: 22 additions & 0 deletions Matrix/LargestLocalValueinMatrix.cpp
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.

0 comments on commit 3a8689e

Please sign in to comment.