Meesho Coding Question – Solved

12 Live
A pixel color RGB is defined as a 24 bit integer. Each 8 bit integer (1 byte) represents either red, green or blue color. Each 8 bit integer has an integer value between 0 (Low intensity) and 255 (High intensity) For the distance between two pixels having RGB values (r1, g1, b1) and (r2, 82, b2), it is calculated as follows: d = square_root( (r1-r2)^2+ (g1-g2)^2+ (b1- b2)^2) Given a 24-bit binary string describing a pixel, identify which of these five colors the pixel is closest to using the Euclidean distance calculation. Then return the closest pure color: Red, Green, Blue, Black, White.

Asked in: Meesho

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |