Apple Interview Question

How to implement a* routing