Teradata Interview Question

Question from algorithms.