401. Binary Watch Easy

@problem@discussion
#Backtracking#Bit Manipulation



1/**
2 * [401] Binary Watch
3 *
4 * A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on the right.
5 * 
6 * 	For example, the below binary watch reads "4:51".
7 * 
8 * <img alt="" src="https://assets.leetcode.com/uploads/2021/04/08/binarywatch.jpg" style="width: 500px; height: 500px;" />
9 * Given an integer turnedOn which represents the number of LEDs that are currently on (ignoring the PM), return all possible times the watch could represent. You may return the answer in any order.
10 * The hour must not contain a leading zero.
11 * 
12 * 	For example, "01:00" is not valid. It should be "1:00".
13 * 
14 * The minute must be consist of two digits and may contain a leading zero.
15 * 
16 * 	For example, "10:2" is not valid. It should be "10:02".
17 * 
18 *  
19 * Example 1:
20 * Input: turnedOn = 1
21 * Output: ["0:01","0:02","0:04","0:08","0:16","0:32","1:00","2:00","4:00","8:00"]
22 * Example 2:
23 * Input: turnedOn = 9
24 * Output: []
25 *  
26 * Constraints:
27 * 
28 * 	0 <= turnedOn <= 10
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/binary-watch/
34// discuss: https://leetcode.com/problems/binary-watch/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn read_binary_watch(turned_on: i32) -> Vec<String> {
40        vec![]
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_401() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.