May you please help in writing a java program which should accept an array of strings defining dependencies. Each string contains the name of a package followed by a colon and space, then any dependencies required by that package. For simplicity we’ll assume a package can have at most one dependency. The program should output a comma separated list of package names in the order of install, such that a package’s dependency will always precede that package. The program should reject as invalid a dependency specification that contains cycles.
Example of valid input KittenService: Leetmeme: Cyberportal Cyberportal: Ice CamelCaser: KittenService Fraudstream: Leetmeme Ice:
A valid output for the above would be:
KittenService, Ice, Cyberportal, Leetmeme, CamelCaser, Fraudstream
Example of input that should be rejected (contains cycles) KittenService: Leetmeme: Cyberportal Cyberportal: Ice CamelCaser: KittenService Fraudstream: Ice: Leetmeme