Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add minCost solution 3603 in Python and Go #4589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Speccy-Rom wants to merge 18 commits into doocs:main from Speccy-Rom:main
Closed
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d3c3c60
feat: add solution for deleting duplicate folders in a file system
Speccy-Rom Jul 20, 2025
593e789
Merge pull request #1
Speccy-Rom Jul 20, 2025
8e85b73
feat: add minCost solution in Python and Go #3603
Jul 21, 2025
dc0b67e
Merge pull request #2
Speccy-Rom Jul 21, 2025
c2a47f5
feat: add solutions to lc problem: No.1948 (#4582)
yanglbme Jul 20, 2025
d64eda2
feat: add solutions to lc problem: No.3618 (#4583)
yanglbme Jul 20, 2025
a4d36fd
feat: add solutions to lc problem: No.3619 (#4586)
yanglbme Jul 20, 2025
89b27cf
feat: update solutions to lc problem: No.1957 (#4587)
yanglbme Jul 20, 2025
571a4d0
feat: add solutions to lc problem: No.3622 (#4588)
yanglbme Jul 20, 2025
f0362dc
Merge branch 'main' into main
Speccy-Rom Jul 22, 2025
80bf294
Merge branch 'main' into main
Speccy-Rom Jul 23, 2025
3a83873
Merge pull request #3
Speccy-Rom Jul 23, 2025
03892a9
Merge branch 'doocs:main' into main
Speccy-Rom Jul 23, 2025
cf601f4
feat: add minTime solutions in Python, C++, and Go for LC problem #3604
Jul 23, 2025
5ef355b
Merge branch 'main' into main
Speccy-Rom Jul 24, 2025
7a51de4
Merge branch 'main' into main
Speccy-Rom Jul 26, 2025
a723fb0
Merge branch 'main' into main
Speccy-Rom Jul 29, 2025
bfd23a2
Merge branch 'main' into main
Speccy-Rom Aug 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add minTime solutions in Python, C++, and Go for LC problem #3604
  • Loading branch information
rom.spiridonov committed Jul 23, 2025
commit cf601f488b01837a0417d833c2eaf5690ad84f19
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
class Solution {
vector<vector<vector<int>>> adj;
vector<int> sol;
priority_queue<pair<int,int> ,vector<pair<int,int>>,greater<>> pq;
void pushNeighbours(int node,int curr){
for(auto it : adj[node]){
int temp = it[0], start = it[1],end = it[2],newTime = curr+1;
if(curr<start) newTime = start+1;
if(newTime < sol[temp] && newTime-1<=end){
pq.push({newTime,temp});
priority_queue<pair<int,int>, vector<pair<int,int>>,greater<>> pq;
void pushNeighbours(int node,int curr){
for(auto it : adj[node]){
int temp = it[0], start = it[1],end = it[2],newTime = curr + 1;
if(curr < start) newTime = start + 1;
if(newTime < sol[temp] && newTime - 1 <= end){
pq.push({newTime,temp});
sol[temp] = newTime;
}
}
}

public:
int minTime(int n, vector<vector<int>>& edges) {
adj = vector<vector<vector<int>>>(n);
for(auto it: edges)
adj[it[0]].push_back({it[1],it[2],it[3]});
sol = vector<int>(n,INT_MAX);
sol[0]=0;
for(pq.push({0,0});!pq.empty();pq.pop())
pushNeighbours(pq.top().second,pq.top().first);
if(sol[n-1] == INT_MAX) return -1;
return sol[n-1];
for(auto it: edges)
adj[it[0]].push_back({it[1],it[2],it[3]});
sol = vector<int>(n,INT_MAX);
sol[0] = 0;
for(pq.push({0,0});!pq.empty();pq.pop())
pushNeighbours(pq.top().second,pq.top().first);
if(sol[n - 1] == INT_MAX) return -1;
return sol[n - 1];
}
};
const auto __ = []() {
Expand Down

AltStyle によって変換されたページ (->オリジナル) /