top of page

Looking to master object-oriented and system design for tech interviews or career growth?

  • Improve your system design and machine coding skills.

  • Study with our helpful resources.

  • Prepare for technical interviews and advance your career.

**We're in beta mode and would love to hear your feedback.

Power Of Two Integers Interviewbit Solution

Problem Description:

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.


Input : 4 
Output : True   
    as 2^2 = 4. 


int Solution::isPower(int A) { 
    if(A==1) return 1;
    for(int i = 2; i < 32; i++){
        for(int j = 2; j <= pow(INT_MAX, 1.0/i); j++){
            if(pow(j, i) == A){
                return 1;
    return 0; 


what is the time complexity of this code for worst case ?

bottom of page