fixing run time complexity for karatsubha