Given a number . The task is to check if the number is formed by concatenating the numbers 1, 14 and 144 only any number of times and in any order.
If it is possible, print YES otherwise print NO.
Input: N = 141411 Output: YES Input: N = 14134 Output: NO
The idea is to fetch single digit, double digit and triple digit numbers from the end and check if any of them matches with 1, 14 and 144 respectively. If any of them matches, divide the number with that and repeat the above step until the number is greater than zero.
Below is the implementation of using above approach:
- Check if the large number formed is divisible by 41 or not
- Check if the number formed by the last digits of N numbers is divisible by 10 or not
- Check if number formed by joining two Numbers is Perfect Cube
- Longest palindromic string formed by concatenation of prefix and suffix of a string
- Check if concatenation of two strings is balanced or not
- Check if a Sequence is a concatenation of two permutations
- Check if the concatenation of first N natural numbers is divisible by 3
- Find the number obtained after concatenation of binary representation of M and N
- Check if B can be formed by permuting the binary digits of A
- Check if a right-angled triangle can be formed by the given coordinates
- Check whether a straight line can be formed using N co-ordinate points
- Check if N rectangles of equal area can be formed from (4 * N) integers
- Check if a right-angled triangle can be formed by moving any one of the coordinates
- Check if an array can be formed by merging 2 non-empty permutations
- Maximum number formed from array with K number of adjacent swaps allowed
- Check if a given string can be formed using characters of adjacent cells of a Matrix
- Check whether a binary string can be formed by concatenating given N numbers sequentially
- Find smallest number formed by inverting digits of given number N
- Find maximum number that can be formed using digits of a given number
- Check if a given circle lies completely inside the ring formed by two concentric circles
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.