Amazon Interview Question

Currency conversion question. How to use Bfs, dfs. I solved it