Browser tab content: Problem List 0 Debugging... Run Submit 00:00:00 Description…
- User
Browser tab content: Problem List 0 Debugging... Run Submit 00:00:00 Description Editorial Editorial Solutions Solutions Submissions Submissions Code Note Note Testcase Testcase Test Result 401. Binary Watch Easy Topics Companies Hint
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.
For example, the below binary watch reads "4:51".
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.
The hour must not contain a leading zero.
For example, "01:00" is not valid. It should be "1:00".
The minute must consist of two digits and may contain a leading zero.
For example, "10:2" is not valid. It should be "10:02".
Example 1:
Input: turnedOn = 1 Output: ["0:01","0:02","0:04","0:08","0:16","0:32","1:00","2:00","4:00","8:00"]
Example 2:
Input: turnedOn = 9 Output: []
Constraints:
0 <= turnedOn <= 10 Seen this question in a real interview before? 1/5 Yes No Accepted 153K Submissions 276.5K Acceptance Rate 55.3% Topics Backtracking Bit Manipulation Companies 0 - 6 months Google 2 6 months ago Amazon 3 Uber 3 Adobe 2 Hint 1 Simplify by seeking for solutions that involve comparing bit counts. Hint 2 Consider calculating all possible times for comparison purposes. Similar Questions Letter Combinations of a Phone Number Medium Number of 1 Bits Easy Discussion (54) Choose a type Preview Comment 💡 Discussion Rules
-
Please don't post any solutions in this discussion.
-
The problem discussion is for asking questions about the problem or for sharing tips - anything except for solutions.
-
If you'd like to share your solution for feedback and ideas, please head to the solutions tab and post it there.
Sort by:Best No comments yet. 1 2 3 4 5 6 Copyright ©️ 2024 LeetCode All rights reserved 1.4K 54 Java Auto 1 2 3 4 5 class Solution { public List readBinaryWatch(int turnedOn) { } } Saved Ln 1, Col 1 You must run your code first
Word Squares - LeetCode
Problem List Tag 327. Count of Range Sum
Hard
- Odd Even Linked List
Med.
- Longest Increasing Path in a Matrix
Hard
- Patching Array
Hard
- Verify Preorder Serialization of a Binary Tree
-
- Assistant
Problem Description:
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.
Given an integer
turnedOnwhich 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.