Hi, I am trying to find the solution for a problem where i have something like
- A > B
- B > C
- B > D
- C > D
And I should get the answer as A > B > C > D.
Conditions for this problem
- The output will involve all the elements.
- The problem will not have any bogus inputs. for example, (A>B) (C>D) is a bogus input, since we cannot determine the output.
- The inputs can be of any size but never bogus and there will always be a solution to the problem.
I need to find a solution for this optimally using Java Collections. Any tips/hints are welcome.
Thanks in advance!