3Di Interview Question

Basic program and pseudo code