Skip to content

Commit fefbaf5

Browse files
authored
Create LargestPair.java
1 parent 744dc9a commit fefbaf5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Easy/LargestPair.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static int LargestPair(int num) {
7+
// code goes here
8+
int maxPair = 0;
9+
int pair = 0;
10+
11+
while (num != 0){
12+
pair = num % 100;
13+
14+
if(pair > maxPair){
15+
maxPair = pair;
16+
}
17+
num /= 10;
18+
}
19+
return maxPair;
20+
}
21+
22+
public static void main (String[] args) {
23+
// keep this function call here
24+
Scanner s = new Scanner(System.in);
25+
System.out.print(LargestPair(s.nextLine()));
26+
}
27+
28+
}

0 commit comments

Comments
 (0)