TeamABeatTeamB, is a Graphs related problem and in this post we will see how we can solve this challenge in C++

Given a list of outcomes between different teams .Outcome is either win or loss. Given Teams A and B .Find if there exists any sequence of teams A...B such that each team has beaten the team on its right i.e if we have say A,C,D,B then A has beaten C ,C has beaten D and D has beaten B. NOTE:the sequence should contain all the teams We can model this as a graph problem. We make an edge from u to v if u has beaten v Then we just need to check if we can reach B from A. We can use BFS as well as DFS Here we use DFS

Please check the main.cpp snippet for the solution.

This solution originally posted at: Github by @susantabiswas