-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray-04
More file actions
62 lines (42 loc) · 1.66 KB
/
Array-04
File metadata and controls
62 lines (42 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Pravin wants to give a surprise to his girlfriend on Valentine's Day. So he decided to give a rose to his girlfriend. He got the Valentine's surprise gift box. In that box, Each section has Multiple roses that are mentioned with some numbers. He needs to choose the best one from the gift box for his girlfriend. so the condition of choosing the rose is mentioned the rose number should be a double-digit integer and at the same time it should be a maximum number of the Integer.
Note - If he didnt find any roses from the box return the statement as "Roses are not Found".
Input Format
First Input Corresponds to no of rose in the box. Second Input Corresponds to numbers mentioned in each rose section.
Constraints
No Constraints
Output Format
Find the best roses from the box to surprise her girlfriend.
Sample Input 0
6
9 15 6 167 55 34
Sample Output 0
The rose he chose from the box is 55
Sample Input 1
7
8 764 678 9 222 7 2
Sample Output 1
Roses are not Found*/
#Answer
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int max = -1;
for (int i = 0; i < n; i++) {
int num = sc.nextInt();
// Check if number is double-digit
if (num >= 10 && num <= 99) {
if (num > max) {
max = num;
}
}
}
if (max == -1) {
System.out.println("Roses are not Found");
} else {
System.out.println("The rose he chose from the box is " + max);
}
}
}