I think you are missing one of the two pieces the question builds on: Linear Algebra (do you know how a dot product is defined?) or Datastructures including their complexity. You would prepare by reading up on whichever of these two you are missing.
If you know how it's supposed to work in theory but struggle to bang it out, you could do eg leetcode.