
Can someone provide some help with this question:
orbit =['Sun)B','B)C','C)D','C)H','B)F'].
Find the total number of direct or indirect orbits. For example, in this orbital diagram, D directly revolves around C, because C directly revolves around B, so
D indirectly revolves around B, and also indirectly around SUN, D has a total of 3 orbits, and C has 2 orbits.
it seems like we need to create a graph using hashmaps and then just traverse it and keep a count of the total number children for each node. However, I am failing at the first step itself. How do I create this graph?
orbit =['Sun)B','B)C','C)D','C)H','B)F'].
graph should be of the form - [{D:{C:{B: Sun}}}, {H:{C:{B: Sun}}}, F:{B: Sun}]