Skip to content

Commit eb13b02

Browse files
solves sherlock and squares
1 parent f55cbd2 commit eb13b02

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ I have also solved other domains on HackerRank that can be viewed at:
5757

5858
### Warmup
5959
| Problem | Difficulty | Solution Link |
60-
|---------|------------|:-------------:|
60+
|---------|:----------:|:-------------:|
6161
| [Solve Me First](https://www.hackerrank.com/challenges/solve-me-first) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/warmup/SolveMeFirst.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/python/warmup/solve-me-first.py) |
6262
| [Simple Array Sum](https://www.hackerrank.com/challenges/simple-array-sum) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/warmup/SimpleArraySum.java) |
6363
| [Compare The Triplets](https://www.hackerrank.com/challenges/compare-the-triplets) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/warmup/CompareTheTriplets.java) |
@@ -72,7 +72,7 @@ I have also solved other domains on HackerRank that can be viewed at:
7272

7373
### Implementation
7474
| Problem | Difficulty | Solution Link |
75-
|---------|------------|---------------|
75+
|---------|:----------:|:-------------:|
7676
| [Grading Students](https://www.hackerrank.com/challenges/grading) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/implimentation/GradingStudents.java) |
7777
| [Apple and Orange](https://www.hackerrank.com/challenges/apple-and-orange) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/implimentation/AppleAndOrange.java) |
7878
| [Kangaroo](https://www.hackerrank.com/challenges/kangaroo) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/implimentation/Kangaroo.java) |
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// https://www.hackerrank.com/challenges/sherlock-and-squares/problem
2+
3+
package implimentation;
4+
5+
import java.util.Scanner;
6+
7+
public class SherlockAndSquares {
8+
9+
public static void main(String[] args) {
10+
Scanner scanner = new Scanner(System.in);
11+
int queries = scanner.nextInt();
12+
while (queries-- > 0) {
13+
int start = scanner.nextInt();
14+
int end = scanner.nextInt();
15+
System.out.println(squaresIn(start, end));
16+
}
17+
}
18+
19+
private static int squaresIn(int start, int end) {
20+
return (int) (Math.sqrt(end)) - (int)(Math.sqrt(start - 1));
21+
}
22+
}

0 commit comments

Comments
 (0)