2045. Second Minimum Time to Reach Destination | Hard | Leetcode Daily (POTD) 28 July 2024 | Java

  Рет қаралды 885

AlgorithmHQ

AlgorithmHQ

Күн бұрын

Пікірлер: 10
@vedictechyog
@vedictechyog 3 ай бұрын
Great!
@QuadbTech
@QuadbTech 3 ай бұрын
Beautifully explained ! ✨
@algorithmsbyaditi
@algorithmsbyaditi 3 ай бұрын
Thank you!
@crekso398
@crekso398 3 ай бұрын
thank you so much ..
@algorithmsbyaditi
@algorithmsbyaditi 3 ай бұрын
Glad you liked it !
@AlokKumar-gp2jq
@AlokKumar-gp2jq 3 ай бұрын
it showing wrong answer
@prettyugly_paintings
@prettyugly_paintings 3 ай бұрын
import java.util.*; class Solution { class Pair{ int node; int weight; Pair(int node, int weight){ this.node = node; this.weight = weight; } } public int secondMinimum(int n, int[][] edges, int time, int change) { ArrayList adj = new ArrayList(); for (int i = 0; i x.weight - y.weight); pq.add(new Pair(1, 0)); while (!pq.isEmpty()) { Pair curr = pq.poll(); int currNode = curr.node; int currTime = curr.weight; if(currNode == n && secDistance[n] != Integer.MAX_VALUE) return secDistance[n]; if ((currTime / change) % 2 == 1) { // Red light currTime = ((currTime/change)+1)*change; } currTime += time; for (int neighbor : adj.get(currNode)) { if(currTime< distance[neighbor]){ secDistance[neighbor] = distance[neighbor]; distance[neighbor] = currTime; pq.add(new Pair(neighbor, currTime)); } else if(currTime> distance[neighbor] && currTime< secDistance[neighbor]){ secDistance[neighbor] = currTime; pq.add(new Pair(neighbor, currTime)); } } } return -1; } }
@VinayKumar-xs6el
@VinayKumar-xs6el 3 ай бұрын
sri krishna k naam lekar english mey explain karo
@AlokKumar-gp2jq
@AlokKumar-gp2jq 3 ай бұрын
shut up
@im_ykp
@im_ykp 3 ай бұрын
Don't you Know Hindi
Turn Off the Vacum And Sit Back and Laugh 🤣
00:34
SKITSFUL
Рет қаралды 3,1 МЛН
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 736 М.
How I make HARD coding problems look EASY
8:04
Sahil & Sarra
Рет қаралды 124 М.
DARKER SIDE of SOFTWARE ENGINEERING !!
12:09
Striver
Рет қаралды 145 М.