Adobe Interview Question

to write pseudocode for the not optimal solution