Hey MIK, thanks for creating such a relevant content on DP. I could finally have a grasp on DP and convert the code from recursion to memoization. Thanks to your. Channel I was able to crack Google coding rounds.
@codestorywithMIK Жыл бұрын
Google Coding rounds. Woww ❤️💪💪 Congratulations on this achievement And thank you for your kind words ❤️❤️
@thekindspill Жыл бұрын
Wow
@AlishaKhan-ww3io Жыл бұрын
Wow. congrats
@anuppatankar4294 Жыл бұрын
Congratulations 👌🏻
@gp70607 ай бұрын
Was able to write code after listening your question explanation . Awesome explanation❤
@GeniusOG Жыл бұрын
I have done this by my own after understanding problem from your video, Thanks for the another great video. 😊
@codestorywithMIK Жыл бұрын
Thank you 😊
@iamnoob7593Ай бұрын
Thank you , Understood. Very well explained
@Raj10185 Жыл бұрын
Thank you so much understand everything
@shikharpandya49272 ай бұрын
Thanks a lot Did it on my own. mission complete graph playlist + dp playlist 😇
@ce019vivek5 Жыл бұрын
Great Explaination 👍
@codestorywithMIK Жыл бұрын
iPad PDF Notes - github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad%20PDF%20Notes/Leetcode-1615-Maximal%20Network%20Rank.pdf **************** JAVA CODE ************** class Solution { public int maximalNetworkRank(int n, int[][] roads) { Map adj = new HashMap(); for (int[] road : roads) { adj.computeIfAbsent(road[0], k -> new HashSet()).add(road[1]); adj.computeIfAbsent(road[1], k -> new HashSet()).add(road[0]); } int maxRank = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int i_rank = adj.getOrDefault(i, Collections.emptySet()).size(); int j_rank = adj.getOrDefault(j, Collections.emptySet()).size(); int rank = i_rank + j_rank; if (adj.getOrDefault(i, Collections.emptySet()).contains(j)) { rank--; } maxRank = Math.max(maxRank, rank); } } return maxRank; } }
@wearevacationuncoverers Жыл бұрын
Thank you for listening to our requests for adding PDF as well. ❣❣
@thekindspill Жыл бұрын
thanks
@anuppatankar4294 Жыл бұрын
Great Video 😍
@codestorywithMIK Жыл бұрын
Thank you 😊
@JoyAcharyatvl Жыл бұрын
Thanks vai, It was awesome. Thanks again.
@codestorywithMIK Жыл бұрын
Thank you 🙏 😇
@NITianMonika Жыл бұрын
Your explanations in very good
@codestorywithMIK Жыл бұрын
Thanks a lot
@umeshbisht1054 Жыл бұрын
Thanku bhaiya ❤
@harikrushnasuhagiya3925 Жыл бұрын
Thanks a lot man.
@AmarjeetKumar-to9ub Жыл бұрын
Thank You :)
@sauravbiswajit8091 Жыл бұрын
Thanksss a lot sir
@codestorywithMIK Жыл бұрын
Most welcome 😇
@floatingpoint7629 Жыл бұрын
thanks for the super explanation. the question was confusing and difficult to understand specially why the -1, but you made it easy.
@codestorywithMIK Жыл бұрын
Thank you 😊
@vaibhavgupta973 Жыл бұрын
thank you
@codestorywithMIK Жыл бұрын
You're welcome😇
@kashishkashyap6229 Жыл бұрын
I was able to solve it myself since I have watched your complete graph concepts Playlist.
@codestorywithMIK Жыл бұрын
Awesome ❤️😇
@manasdeora4601 Жыл бұрын
Very beautifully explained. Thanks bro
@codestorywithMIK Жыл бұрын
Thank you so much ❤️❤️
@rabeakhatun2819 Жыл бұрын
Nice dada , another similar problem on this is on triplets in leetcode
@codestorywithMIK Жыл бұрын
Thank you 😊
@oqant0424 Жыл бұрын
i am happy that i was able to solve it on myself (though i did some mistakes but after watching only few minutes i realised where i was wrong and then corrected them and it passed).............thanks for teaching us ki sawal karte kaise karte hain
@codestorywithMIK Жыл бұрын
Awesome Thank you ❤️😇
@YashSinghal Жыл бұрын
what makes your videos best is you never assume that the viewer knows it already, you even explain the question with time and patience ❤
@codestorywithMIK Жыл бұрын
Thanks a lot Yash 😇🙏
@unknown478964 ай бұрын
my basic observation approach by degrees class Solution { public: int maximalNetworkRank(int n, vector& roads) { unordered_map adj; vector degree(n,0); for(auto it: roads) { adj[it[0]].push_back(it[1]); adj[it[1]].push_back(it[0]); degree[it[0]]++; degree[it[1]]++; } int maxi=INT_MIN; for(int i=0;i
@xiaoshen194 Жыл бұрын
I was also thinking about indegree-ish kind of algo. Good explanation. Thnx 👍
@keertilata20 Жыл бұрын
same
@souvikmukherjee8245 Жыл бұрын
At first, this question seemed daunting 😳, but your explanation made it appear much simpler 😌.
@codestorywithMIK Жыл бұрын
Glad it was helpful! ❤️😇🙏
@NeerajKumar-cj6ky Жыл бұрын
Your video is fantastic but i want to request that please tell the time complexity in little more brief and also space complexity.
@codestorywithMIK Жыл бұрын
Sure thing ❤️❤️❤️
@__VishalSharma Жыл бұрын
Bhai thank you for these videoes pls also start the weekly contest post discussion on the channel.
@AlishaKhan-ww3io Жыл бұрын
Thanks a lot
@ugcwithaddi Жыл бұрын
Legend
@neelx9437 Жыл бұрын
Bhaiya in the description its written 32nd video of sliding window playlist instead of graphs. Again thanks bhaiya for maintaining my consistency❤❤. Here's my java code- class Solution { public int maximalNetworkRank(int n, int[][] roads) { int maxRank = 0; List adj=new ArrayList(); for(int i=0;i
@codestorywithMIK Жыл бұрын
Wow. Thanks a lot for mentioning. Corrected ❤️❤️
@sauravchandra10 Жыл бұрын
Surprisingly brute force wala code accept hogya
@codeandtalk6 Жыл бұрын
❤❤
@thekindspill Жыл бұрын
You made it look so easy
@abhishekverma7604 Жыл бұрын
isko kahns algorithm se bhi kar skte hn,like creating indegree array and then performing plain bfs..
@shahchandan820811 ай бұрын
Sir please also upload the graph concept lecture IPad notes . Bahut jada help ho jaega sir.
@souravjoshi2293 Жыл бұрын
Thanks a lot man. Crystal clear
@aswithasai4015 Жыл бұрын
But there will be log n complexity for insertion in set right
@codestorywithMIK Жыл бұрын
The insert operation in unordered_set in C++ has Average Time complexity of O(1) en.cppreference.com/w/cpp/container/unordered_set ❤️❤️
@aswithasai4015 Жыл бұрын
@@codestorywithMIK ohh ok thank you
@taneyasoni Жыл бұрын
18/31 #augustchallengewithMIK
@kamalkothari4843 Жыл бұрын
will the road numbers be 0,1,2,3,... or it can be random 2,5,7, etc
@kamalkothari4843 Жыл бұрын
and how to solve if road number is random
@xiaoshen194 Жыл бұрын
@@kamalkothari4843adj list se
@souravjoshi2293 Жыл бұрын
It's mentioned in the constraint 0
@thekindspill Жыл бұрын
use adjacency list then
@codestorywithMIK Жыл бұрын
Yes, In that case we will have to use adjacency list of (int, vector)
@santhosh7042 Жыл бұрын
i taught it can be solved by floyd warshall 😅
@dayashankarlakhotia4943 Жыл бұрын
class solution { Public int maximal Network Rank(int n,int [][]roads){ list []graph =new Array list (); for (int i=0; i
@jayendraawasthi2646 Жыл бұрын
using your second approach i tried doing the question in O(n) time complexity by just getting the maximum and second maximum values in degree array. It is working for almost 80+ test cases but fails in a very big test case. Can anyone tell me where i'm going wrong please. CODE: class Solution { public: int maximalNetworkRank(int n, vector& roads) { vector arr(n, 0); vector mat(n, vector(n, false)); for(auto road: roads){ int e1 = road[0]; int e2 = road[1]; arr[e1]++; arr[e2]++; mat[e1][e2] = true; mat[e2][e1] = true; } int maxi=0, secMaxi=-1; int res = INT_MIN; for(int i=1; i= arr[maxi]){ secMaxi = maxi; maxi = i; } else { if(secMaxi == -1){ secMaxi = i; } else if(arr[i] >= arr[secMaxi]) { secMaxi = i; } } int rank = arr[maxi] + arr[secMaxi]; if(mat[maxi][secMaxi]) rank--; res = max(res, rank); } return res; } };
@codestorywithMIK Жыл бұрын
Yeah actually this will not pass all test cases
@AnandKumar-kz3ls Жыл бұрын
i also tried to do this in O(N) but then realize if its a complete graph then there will be (n*(n-1)/2) edges which is eventually O(n^2)
@priyanshusingh3316 Жыл бұрын
chalo graph se darr thoda kam ho gaya hai
@codestorywithMIK Жыл бұрын
So glad to know ❤️😇
@keertilata20 Жыл бұрын
i was stuck on how to find if two cities are connected to each other or not
@thekindspill Жыл бұрын
Same. But got it cleared in starting minutes of the video and got it done myself
@manaskhare412 Жыл бұрын
Great video, but I would like to point out the mistake that you have made in your 1st code, if(adj[i].find(j) != adj[i].end()) { total--; } which is this line, it's nothing to do with finding common roads, and it's surprising how your code got accepted 😂, All confused folks, use this code, and get your confusion clear 👇 if(adj[i].find(j) != adj[i].end()) { if(adj[j].find(i) != adj[j].end()) { total--; } }
@codestorywithMIK Жыл бұрын
Hi Manas , Sorry I didn’t get your code. Can you please elaborate a little ? adj[i].find(j) itself checks if i and j are connected (and since it’s bidirectional, we don’t have to check j to i)
@ugcwithaddi Жыл бұрын
Bhai , it’s an un directed graph 😅. No need to check for both condition. 😅
@souravjoshi2293 Жыл бұрын
If i is connected to j, then there is no need to check for (j to i) bro. Both checks are not required.