add o(n) solution for gaoe-of-rotation