I have Map<String, String>
which contains elements like: {“a”=”b”, “b”=”c”, “c”=”d”, “z”=”y”, …}.
I need a method:
List<String> getTransitiveKeys(String startKey);// assuming the map is visible somehow as `map`
When getTransitiveKeys(“a”)
is called, it will return [“a”, “b”, “c”]. When getTransitiveKeys (“z”)
is called, it will return [“z”].
Recursion needed in the method?
Thanks!