Power Of Two Integers

Given a positive integer which fits in a 32 bit signed integer, find if it can be expressed as A^P where P > 1 and A > 0. A and P both should be integers.

Example

Input : 4
Output : True  
as 2^2 = 4. 
Interview Code Editor
Hints
  • Hint 1
  • Solution Approach
  • Complete Solution
7436 successful submissions.
Asked In:
  • Housing
  • Amazon
Click here to jump start your coding interview preparation