Amazon Interview Question

About the second or different approach for the same assessment which one attempted.