Desquared interview question

Write a small function that performs an asked operation Questions about algorithms complexity