Solve a medium-level algorithmic challenge involving array manipulation or graph traversal, focusing on optimal time and space complexity.
Implement shortest_path(graph, start, target) for a directed graph represented by an adjacency list. Return a shortest path including both endpoints, or [] when the target is unreachable. For equal-length paths, follow neighbors in their listed order.
Example: graph = [[1, 2], [3], [3], []], start = 0, target = 3 returns [0, 1, 3]. Nodes are integer indices from 0 through len(graph) - 1.
def shortest_path(graph, start, target):