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.
function squares(a: number, b: number): number {
// Write your code here
let squaresCount: number = 0
let lower: number = Math.ceil(Math.sqrt(a))
let upper: number = Math.floor(Math.sqrt(b))
let squaresSet: Set<number> = new Set()
for (let i = lower; i <= upper; i++) {
squaresSet.add(i * i)
}
console.log(`lower: `${lower}, upper: $`{upper}, squareSet: ${Array.from(squaresSet)}`)
return squaresSet.size
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Squares
You are viewing a single comment's thread. Return to all comments →
function squares(a: number, b: number): number { // Write your code here let squaresCount: number = 0
}