Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5765 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4993 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1286 |

@bt8816103042 | 739 |

@rohitanand | 495 |

@codeantik | 479 |

@shalinibhataniya1097 | 472 |

@amrutakashikar2 | 464 |

@thealchemist627 | 456 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@dalwainazism125 | 453 |

@SherlockHolmes3 | 447 |

Complete Leaderboard |

Given two given numbers **a** and **b** where 1<=a<=b, find the number of perfect squares between a and b (a and b inclusive).

**Example 1:**

Input:a =9,b =25Output:3Explanation:There are 3 perfect squares between 9 and 25. They are 9, 16, and 25.

**Example 2:**

Input:a =1,b =7Output:2Explanation:There are 2 perfect squares between 1 and 7. They are 1, and 4.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **numOfPerfectSquares()** which takes 2 Integers a and b as input and returns the number of perfect squares between a and b.

**Expected Time Complexity:** O(1)

**Expected Auxiliary Space:** O(1)

**Constraints:**

1 <= a <= b <= 10^{5}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Perfect Squares in a Range

...