21 Comments

User's avatar
dmviper's avatar

Just wanted to point out, as is typical with whiteboard questions, there's a small indexing error that's hard to spot unless you know a few easy edge cases to check. FromMinY and FromMaxY would be the same and you would skip the outer for loop entirely even if FromMinX and FromMaxX were different.

It's the classic: if you have books 2 through 5 of a series you have 4 books problem.

Love the content though, it's really interesting to see what interview questions back in 1994 looked like.

Expand full comment
Connor A. Haskins's avatar

1) Wouldn't calling memcpy instead of having an inner loop be more concise?

2) Let's say your buffer width was something like 2160 and your rectangle had a width of 2000. Is there any performance benefit potential from using something like memcpy?

3) In an interview, it feels like they often want you to think about the edge cases. In this case, I would point out the possibility that the rect from the source buffer might be too large for the destination buffer and position. This solution wouldn't handle that intuitively.

Expand full comment
19 more comments...

No posts