We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Sherlock and Squares
Sherlock and Squares
Sort by
recency
|
1584 Discussions
|
Please Login in order to post a comment
Case 6 was 'failing' because of a print statement used for debugging... Success after removing print statement (which should have no effect on result)
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; }
c++
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
}
Java solution :