Sort by

recency

|

1584 Discussions

|

  • + 0 comments

    Case 6 was 'failing' because of a print statement used for debugging... Success after removing print statement (which should have no effect on result)

  • + 0 comments

    My JavaScript Solution function squares(a, b) { const start = Math.ceil(Math.sqrt(a)); const end = Math.floor(Math.sqrt(b));
    return end - start + 1 > 0 ? end - start + 1 : 0; }

  • + 0 comments

    c++

    int squares(int a, int b) {
        int start = ceil(sqrt(static_cast<double>(a)));
        int end = floor(sqrt(static_cast<double>(b)));
        
        if (end < start) return 0;
        
        return end - start + 1;
    }
    
  • + 0 comments

    Javascript simple solution: function squares(a, b) { const lower = Math.ceil(Math.sqrt(a)) const upper = Math.floor(Math.sqrt(b)) return upper-lower+1

    }

  • + 0 comments

    Java solution :

    public static int squares(int a, int b) {
        int startVal = (int)Math.sqrt(a);
        int endVal = (int)Math.sqrt(b);
        int sqrtcount = 0;
    
        for(int i=startVal ; i<=endVal ; i++) {
            int square = i*i;
            if(square>=a && square<=b) {
                sqrtcount++;
            }
        }
    
        return sqrtcount;
    }