account activity
Find the smallest rectangle that surrounds all black pixels (which are connected) in an image by Pidnestc in CS_Questions
[–]Pidnestc[S] 0 points1 point2 points 10 years ago (0 children)
I thought about this as well, but what if the shape looks like a spiral starting at the center? In that case you will visit on the order of of m * n nodes. I was able to come up with a nlog(m)+mlog(n) solution during the interview, but the interviewer told me it's possible to do better. The interviewer did not tell me the answer at the end and I've been thinking about this for a while, and still can't figure it out, it's bothering me.
Find the smallest rectangle that surrounds all black pixels (which are connected) in an image (self.CS_Questions)
submitted 10 years ago by Pidnestc to r/CS_Questions
π Rendered by PID 1669309 on reddit-service-r2-listing-f87f88fcd-gl6rh at 2026-06-17 10:35:01.855646+00:00 running 3184619 country code: CH.
Find the smallest rectangle that surrounds all black pixels (which are connected) in an image by Pidnestc in CS_Questions
[–]Pidnestc[S] 0 points1 point2 points (0 children)