Skip to content

Missing Test Case - 970. Powerful Integers #2214

@IgorRud

Description

@IgorRud

Your LeetCode username

igor84

Category of the bug

  • Question
  • Solution
  • Language

Description of the bug

A solution is accepted but fails on the following test case:

23
1
250000

Code you used for Submit/Run operation

class Solution {
    public List<Integer> powerfulIntegers(int x, int y, int bound) {
        Set<Integer> set = new HashSet();
        int sum = 0; int N = (int) (6.0/Math.log10(2));

        if(x==1 && y==1) {
            if(2<=bound){
                set.add(2);
            }
            return new ArrayList(set);
        }
        if(x==1){
            for(int i=0; i<=N; i++){
                sum = 1+(int)Math.pow(y,i);
                if(sum<=bound) set.add(sum);
            }
            return new ArrayList(set);
        }
        if(y==1){
            for(int i=0; i<=N; i++){
                sum = 1+(int)Math.pow(x,i);
                if(sum<=bound) set.add(sum);
            }
            return new ArrayList(set);
        }
        for (int i=0; i<=N; i++){
            for(int j=0; j<=N; j++){
                sum =(int)( Math.pow(x,i)+Math.pow(y,j));
                if(sum<=bound) set.add(sum);
            }
        }
        return new ArrayList(set);
    }
}

Language used for code

Java

Expected behavior

The solutions should not be accepted since it fails on the test case

Screenshots

image

Additional context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions