3372. Maximize the Number of Target Nodes After Connecting Trees I | Graph | BFS | Greedy

  Рет қаралды 1,372

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 13
@ARYANMITTAL
@ARYANMITTAL Ай бұрын
C++ Code - leetcode.com/problems/maximize-the-number-of-target-nodes-after-connecting-trees-i/submissions/1467124643/ Please do share with your friends or social media, it will be super super helpful 🥺
@kshitijvarma2566
@kshitijvarma2566 Ай бұрын
loved the way of explanation..... crystal clear ....
@Glitch40417
@Glitch40417 Ай бұрын
Nice explanation bro. I remember watching your videos when I didn't get the easy daily leetcode questions. Today I just heard you explaining this question and I understood what to do. Thanks for your work.
@bd1a0573
@bd1a0573 Ай бұрын
Very Good Explaination. Please Make Such Video For Every weekly and Bi-Weekly Contest. GodDamn You Explained it like a Master(ofcourse you are one). you earned a new sub bro. DOUBT :- How to build that intuition. I just got afraid after seeing Tree question in todays contest.
@EtherAtlas
@EtherAtlas Ай бұрын
thank you
@arjunkumaryadav8102
@arjunkumaryadav8102 Ай бұрын
Please tell the linear time complexity approach
@Engineering.Wallah
@Engineering.Wallah Ай бұрын
13:30 many cheaters used dfs
@goldenx2417
@goldenx2417 Ай бұрын
Bhaiya please provide cpp solution it is humble request 🙏
@ARYANMITTAL
@ARYANMITTAL Ай бұрын
Sure sir, adding in description ❤️
@gururajm1
@gururajm1 Ай бұрын
Bro Please solve Q2
@GospodinStanoje
@GospodinStanoje Ай бұрын
class Solution { public: int getLargestOutlier(vector& nums) { const int n = nums.size(); int result = INT_MIN; int total_sum = accumulate(nums.begin(), nums.end(), 0); multiset multiset(nums.begin(), nums.end()); for (const int& outliner : nums) { if ((total_sum - outliner) & 1) // Odd continue; int target = (total_sum - outliner) / 2; multiset.erase(multiset.find(outliner)); if (multiset.find(target) != multiset.end()) result = max(result, outliner); multiset.insert(outliner); } return result; } };
@amitprajapat5697
@amitprajapat5697 Ай бұрын
bro first solve LC 3371
@GospodinStanoje
@GospodinStanoje Ай бұрын
Here you go: class Solution { public: int getLargestOutlier(vector& nums) { const int n = nums.size(); int result = INT_MIN; int total_sum = accumulate(nums.begin(), nums.end(), 0); multiset multiset(nums.begin(), nums.end()); for (const int& outliner : nums) { if ((total_sum - outliner) & 1) // Odd continue; int target = (total_sum - outliner) / 2; multiset.erase(multiset.find(outliner)); if (multiset.find(target) != multiset.end()) result = max(result, outliner); multiset.insert(outliner); } return result; } };
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН