Flood fill on a large grid
You're implementing flood fill on a large pixel grid drawn with a collection view (say, 500×500). If you don't use recursive DFS, how would you write the traversal?
You're implementing flood fill on a large pixel grid drawn with a collection view (say, 500×500). If you don't use recursive DFS, how would you write the traversal?
Recursive DFS on 500×500 piles up a call stack as deep as the pixel count and overflows, so switch to an iterative BFS: put the start coordinate in a queue, pop it, push the four same-colored neighbors, and mark visited by changing the color right away.
CS fundamentals and algorithmsShort answerAdvanced
An image mask comes as an N×M grid where 1 is foreground and 0 is background. How would…
#flood-fill #bfs
UIKitShort answerBasics
How would you write a function that starts at a root view and finds a view matching some…
#bfs
UIKitShort answerBasics
In a UIKit collection view with image cells, fast scrolling makes the previous request's…
#collection-view
ArchitectureShort answerAdvanced
On a UIKit cart screen, the product card is used in the list, in search, and in…
#collection-view