• + 0 comments

    There is no need to loop in the given range:

    We can calculate with just the boundaries in O(1) as here:

    floor(sqrt(b)) - ceil(sqrt(a)) + 1
    

    Explained in https://www.hackerrank.com/challenges/sherlock-and-squares/forum/comments/859695