Java 100%, simplified topological sort, no tree/graph needed
Simplified topological sort, keep iterate cities that can be reached by flipping direction until all cities can be reached.\n\nclass Solution {\n    public int 
Simplified topological sort, keep iterate cities that can be reached by flipping direction until all cities can be reached.\n```\nclass Solution {\n    public int minReorder(int n, int[][] connections) {\n        boolean[] reach = new boolean[n]; // this array tracks cities reachable so far\n        reach[0] = true; //mark city 0 as reachable\n        int sum = 0; // result\n        int count = 1; // this counter counts how many reachable cities, once it reaches n, terminate\n        while (count < n){ \n            for (int[] connection : connections){\n                int source = connection[0], destination = connection[1];\n\t\t\t\t\n\t\t\t\t//if destination is reachable, but source is not, source can be marked as reachable\n                if (reach[destination] && !reach[source]) {\n                    reach[source] = true;\n                    count++;\n                    continue;\n                }\n\t\t\t\t\n                //if source is reachable, but destination is not, we can flip the direction and mark destination reachable.\n                if (reach[source] == true && !reach[destination]){\n                    reach[destination] = true;\n                    connection[0] = destination;\n                    connection[1] = source;\n                    count++;\n                    sum ++;\n                }\n            }\n        }\n        return sum;\n    }\n}\n```
[]