KZ
bin
Негізгі бет
Қазірдің өзінде танымал
Тікелей эфир
Ұнаған бейнелер
Қайтадан қараңыз
Жазылымдар
Кіру
Тіркелу
Ең жақсы KZbin
Фильм және анимация
Автокөліктер мен көлік құралдары
Музыка
Үй жануарлары мен аңдар
Спорт
Ойындар
Комедия
Ойын-сауық
Тәжірибелік нұсқаулар және стиль
Ғылым және технология
Number of pairs | GFG POTD 25th August 2024 | JAVA | C++
18:05
G-28. Shortest Path in Undirected Graph with Unit Weights
16:32
POV: Your kids ask to play the claw machine
00:20
Проверил Лайфхак ОГОНЬ-ТРЕНИЕМ Сахар+Марганцовка #фрост #shorts #frost #лайфхаки #лайфхак #выживание
00:56
отомстил?
00:56
СИНИЙ ИЛИ ЗЕЛЕНЫЙ, КТО ПОБЕДИТ?! #Shorts #Глент
01:00
Shortest path in Undirected Graph | GFG POTD 21st Aug 2024 | JAVA | C++
Рет қаралды 421
Facebook
Twitter
Жүктеу
1
Жазылу 313
CodeCraft Academy
Күн бұрын
#gfgpotd #gfgpotdtoday #potd #gfgproblemoftheday #problemoftheday
Пікірлер: 3
@ajinkyajain2302
28 күн бұрын
C++ Code : vector shortestPath(vector& edges, int N,int M, int src){ // code here vector adj(N); for (const auto& edge : edges) { adj[edge[0]].push_back(edge[1]); adj[edge[1]].push_back(edge[0]); } // Distance array vector dis(N, INT_MAX); dis[src] = 0; // BFS queue q; q.push(src); while (!q.empty()) { int cur = q.front(); q.pop(); for (int nbr : adj[cur]) { if (dis[cur] + 1 < dis[nbr]) { dis[nbr] = dis[cur] + 1; q.push(nbr); } } } // Replace unreachable nodes' distance with -1 for (int i = 0; i < N; ++i) { if (dis[i] == INT_MAX) { dis[i] = -1; } } return dis; }
@ajinkyajain2302
28 күн бұрын
JAVA Code : public int[] shortestPath(int[][] edges,int n,int m ,int src) { // Code here ArrayList adj = new ArrayList(); for(int i = 0 ; i < n ; ++i){ adj.add(new ArrayList()); } for(int[] edge : edges){ adj.get(edge[0]).add(edge[1]); adj.get(edge[1]).add(edge[0]); } int[] dis = new int[n]; Arrays.fill(dis, Integer.MAX_VALUE); dis[src] = 0; Queue q = new LinkedList(); q.add(src); while(!q.isEmpty()){ int cur = q.poll(); for(int nbr : adj.get(cur)){ if(dis[cur] + 1 < dis[nbr]){ dis[nbr] = dis[cur] + 1; q.add(nbr); } } } for(int i = 0; i < n; ++i){ if(dis[i] == Integer.MAX_VALUE){ dis[i] = -1; } } return dis; }
@creativesruffs5008
28 күн бұрын
subscribed
18:05
Number of pairs | GFG POTD 25th August 2024 | JAVA | C++
CodeCraft Academy
Рет қаралды 412
16:32
G-28. Shortest Path in Undirected Graph with Unit Weights
take U forward
Рет қаралды 168 М.
00:20
POV: Your kids ask to play the claw machine
Hungry FAM
Рет қаралды 15 МЛН
00:56
Проверил Лайфхак ОГОНЬ-ТРЕНИЕМ Сахар+Марганцовка #фрост #shorts #frost #лайфхаки #лайфхак #выживание
FROST
Рет қаралды 7 МЛН
00:56
отомстил?
История одного вокалиста
Рет қаралды 5 МЛН
01:00
СИНИЙ ИЛИ ЗЕЛЕНЫЙ, КТО ПОБЕДИТ?! #Shorts #Глент
ГЛЕНТ
Рет қаралды 6 МЛН
8:46
Sorting Elements of an Array by Frequency | GFG POTD 28 Aug 2024 | JAVA | C++
CodeCraft Academy
Рет қаралды 185
13:49
Shortest Path Visiting All Nodes | Leetcode 847 | Live coding session 🔥🔥 | BFS + Bit Manipulation
Coding Decoded
Рет қаралды 19 М.
15:12
My 10 “Clean” Code Principles (Start These Now)
Conner Ardman
Рет қаралды 223 М.
14:12
Minimum number of deletions and insertions | GFG POTD 3rd Sep 2024 | JAVA | C++
CodeCraft Academy
Рет қаралды 182
16:17
A* Search: How Your Map Applications Find Shortest Routes
Reducible
Рет қаралды 52 М.
26:36
G-27. Shortest Path in Directed Acyclic Graph - Topological Sort
take U forward
Рет қаралды 219 М.
12:20
but what is 'a lifetime?
leddoo
Рет қаралды 72 М.
8:48
Your backend is too complicated
Isaac Harris-Holt
Рет қаралды 82 М.
30:18
Shortest Path in Weighted undirected graph | Dijkstra's | Why not BFS ? | Graph Concepts & Qns - 27
codestorywithMIK
Рет қаралды 7 М.
19:22
The hidden beauty of the A* algorithm
Polylog
Рет қаралды 862 М.
00:20
POV: Your kids ask to play the claw machine
Hungry FAM
Рет қаралды 15 МЛН