Solve grid path and top‑k frequency | Meta Interview Question