Genpact Interview Question

Example of code in Matlab