Given a positive integer N, the task is to check whether the binary equivalent of that integer ends with a given string str or not.
Print “Yes” if it ends in “str”. Otherwise, Print “No”.
Input: N = 23, str = “111”
Binary of 23 = 10111, which ends with “111”
Input: N = 5, str = “111”
Approach: The idea is to find the Binary Equivalent of N and check if str is a Suffix of its Binary Equivalent.
Below is the implementation of above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check whether the binary equivalent of a number ends with "001" or not
- Check whether two strings are equivalent or not according to given condition
- Check if a number ends with another number or not
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Find if a string starts and ends with another given string
- Convert the given BCD to its equivalent Binary form
- Sum of decimal equivalent of all possible pairs of Binary representation of a Number
- Program to check whether the given number is Buzz Number or not
- Check whether the given number is Euclid Number or not
- Check whether given number N is a Moran Number or not
- Check whether a given number N is a Nude Number or not
- Check whether a given number is an ugly number or not
- Check whether a given string is Heterogram or not
- Maximum decimal equivalent possible among all connected components of a Binary Valued Graph
- Python | Check if a given string is binary string or not
- Check whether a given number is Polydivisible or Not
- Check whether a given Number is Power-Isolated or not
- Check whether the given number is Wagstaff prime or not
- Check whether a number has consecutive 0's in the given base or not
- Check whether a binary string can be formed by concatenating given N numbers sequentially
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.
Improved By : shubham prakash 1