Amazon Interview Question

Design an algorithm to detect black and white pixels and use it to write a bucket fill function for an image.