Ad
  • Custom User Avatar

    The complexity is actually O(2^2n)) (you only need log(n) bits to represent row and col). However, you still cannot do better than O(row * col) (which is what I assume you meant), as that's also the size of the output.