Given two large numbers as strings, find if one is the power of another. For Example :
Input : a = "374747", b = "52627712618930723" Output : YES Explanation : 374747^3 = 52627712618930723 Input : a = "2", b = "4099" Output : NO
Prerequisite : Multiply two large numbers represented as string
The approach is simple. First, find smaller of the two strings and then multiply it with itself until it becomes equal to or greater than the larger string. If they are equal, return true, else return false.
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.
- Sub-strings that start and end with one character and have at least one other
- Count of strings that become equal to one of the two strings after one removal
- Check if two strings can be made equal by swapping one character among each other
- Minimize count of given operations required to make two given strings permutations of each other
- Meta Strings (Check if two strings can become same after a swap in one string)
- Find power of power under mod of a prime
- Find the sum of power of bit count raised to the power B
- Check if given number is a power of d where d is a power of 2
- Find if a string is interleaved of two other strings | DP-33
- Check if given string can be formed by two other strings or their permutations
- C Program to check if two given strings are isomorphic to each other
- Check if two given strings are isomorphic to each other
- Compute power of power k times % m
- Larger of a^b or b^a (a raised to power b or b raised to power a)
- Highest power of a number that divides other number
- Check if two strings are permutation of each other
- Check whether two strings are anagrams of each other using unordered_map in C++
- Check whether two strings are anagram of each other
- Count of N size strings consisting of at least one vowel and one consonant
- Find two numbers whose difference of fourth power is equal to N
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.