aym O(n^3)