Given a string str representing an integer and an integer led which is the count of LEDs available. The task is to check if it is possible to display the number using the given LEDs.
Note that a digit will be displayed as it is displayed on a 7 segment LED. If its possible to display the number then print Yes, otherwise print No.
Here’s an example of seven segment display:
Input: str = “999”, led = 5
9 takes 6 LEDs to be displayed. So 999 will require 18 LEDs
Since only 5 LEDs are available, it is not possible to display 999
Input: str = “123456789”, led = 43
Input: str = “123456789”, led = 20
Approach: Pre-compute the number of segments used by digits from 0 to 9 and store it. Now for each element of the string count the number of segments used by it. Now, if count ≤ led then print YES else print NO.
The number of segment used by digit:
0 -> 6
1 -> 2
2 -> 5
3 -> 5
4 -> 4
5 -> 5
6 -> 6
7 -> 3
8 -> 7
9 -> 6
Below is the implementation of the above approach:
- Check if mirror image of a number is same if displayed in seven segment display
- Maximum segment value after putting k breakpoints in a number
- Maximize the given number by replacing a segment of digits with the alternate digits given
- Maximum number that can be display on Seven Segment Display using N segments
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if a number is divisible by all prime divisors of another number
- Check if a number with even number of digits is palindrome or not
- Program to check whether a number is Proth number or not
- Segment Tree | Set 1 (Sum of given range)
- Check if a number is a power of another number
- Check if given number is Emirp Number or not
- How to check if a given number is Fibonacci number?
- Check if a number is an Unusual Number or not
- Check if a number is a Trojan Number
- Check whether a number is Non-hypotenuse number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.