Possible Bipartition | Bipartite graph | Graph coloring | Leetcode

Описание к видео Possible Bipartition | Bipartite graph | Graph coloring | Leetcode

This video explains a very important programming interview problem which is to find if we can divide all the incompatible persons into 2 different SETs.This is a very important problem for FAANG companies.The problem is based on finding possible bipartition.In case we have a possible bipartition then we will return true otherwise false.I have given 2 methods to solve this problem. The first one is just an idea about how to solve this using two MAPs or two SETs.The second approach is by using the classical bipartite graph algorithm.I have explained the intuition for solving this problem using graph algorithm.I have shown how this problem is reduced to just finding if a graph is bipartite then just return TRUE saying that it is possible to divide the incompatible persons into 2 different SETs.I have also shown how we canuse the graph coloring algorithm to solve this problem using 2-colors method of coloring graph. We have used only 2-color method because this is used to find if we have an ODD cycle length or an EVEN cycle length.Since, a bipartite graph never have an ODD length cycle, so, if we find any ODD length cycle then the graph will not be bipartite and hence it will not be possible to divide all incompitable persons into 2 different SETs.I have shown the working of algorithm followed by CODE walkthrough in C++ at the end of the video. CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)

=================================================================
INSTAGRAM:   / surya.pratap.k  
LinkedIn:   / surya-pratap-kahar-47bb01168  
=================================================================

CODE LINK: https://gist.github.com/SuryaPratapK/...
SIMILAR PROBLEMS:-
Detect cycle in an undirected graph | Graph coloring method:    • Detect cycle in an undirected graph |...  
Detect cycle in a directed graph:    • Detect cycle in a directed graph  

Комментарии

Информация по комментариям в разработке