Company: Linkdin_2feb
Difficulty: medium
Closest Color Problem Description A pixel colour is stored as a 24-bit value. It is split into three 8-bit groups (one byte each) holding the red, green and blue intensities, in that order. Each byte is an integer from 0 (low intensity) to 255 (high intensity). The distance between two pixels with values (r1, g1, b1) and (r2, g2, b2) is the Euclidean distance: d = sqrt( (r1 - r2)^2 + (g1 - g2)^2 + (b1 - b2)^2 ) Five pure colours are defined: Pure Color R G B Black 0 0 0 White 255 255 255 Red 255 0 0 Green 0 255 0 Blue 0 0 255 You are given n pixels, each written as a 24-bit binary string. For each pixel, report which of the five pure colours it is closest to, using the distance above. If two or more pure colours are tied for the smallest distance, report Ambiguous instead. Function Description Complete the function closestColor in the editor below. closestColor has the following parameter(s): string pixels[n] : the pixels, each a 24-bit binary string in the order red, green, blue Retur