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:
- Sum of the series 3, 20, 63, 144, ......
- Program to find the Nth term of the series 3, 20, 63, 144, 230, ……
- Longest palindromic string formed by concatenation of prefix and suffix of a string
- Length of the smallest number which is divisible by K and formed by using 1's only
- 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
- Sum of product of all subsets formed by only divisors of N
- Find the count of numbers that can be formed using digits 3, 4 only and having length at max N.
- Find position of given term in a series formed with only digits 4 and 7 allowed
- Count of substrings formed using a given set of characters only
- Count subarrays consisting of only 0's and only 1's in a binary array
- Find the number obtained after concatenation of binary representation of M and N
- Pairs whose concatenation contain all digits
- Caesar Concatenation
- Count of digits after concatenation of first N positive integers
- Minimum flips required to convert given string into concatenation of equal substrings of length K
- Count pair of strings whose concatenation has every vowel
- Count of pairs of strings whose concatenation forms a palindromic string
- Check if the large number formed is divisible by 41 or not
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.