-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution2.java
More file actions
27 lines (23 loc) · 916 Bytes
/
Solution2.java
File metadata and controls
27 lines (23 loc) · 916 Bytes
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
class Solution2 {
public boolean increasingTriplet(int[] nums) {
for (int i = 0; i < nums.length; i++) {
for (int j = i + 1; j < nums.length; j++) {
for (int k = j + 1; k < nums.length; k++) {
if (nums[i] < nums[j] && nums[j] < nums[k]) {
return true;
}
}
}
}
return false;
}
public static void main(String[] args) {
Solution2 solution = new Solution2();
int[] nums1 = {1, 2, 3, 4, 5};
System.out.println(solution.increasingTriplet(nums1)); // Output: true
int[] nums2 = {5, 4, 3, 2, 1};
System.out.println(solution.increasingTriplet(nums2)); // Output: false
int[] nums3 = {2, 1, 5, 0, 4, 6};
System.out.println(solution.increasingTriplet(nums3)); // Output: true
}
}