Solution: Binary Watch

Let’s solve the Binary Watch problem using the Backtracking pattern.

Statement

A binary watch has 4 LEDs for displaying hours (ranging from 0 to 11) and 6 for displaying minutes (ranging from 0 to 59). Each LED can be on (1) or off (0), with the least significant bit on the right. For example, the binary watch below reads “9:22.”

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.