Problem Statement
In math, we sometimes define a partial order on some objects. In this problem we will take a look at one possible way how to define a partial order on sets of integers.
Consider two sets of integers: X and Y. These two sets can be related to each other in four possible ways:
- X is equal to Y if each element of X is also an element of Y and vice versa.
- X is less than Y if X is not equal to Y (see previous item) and each element of X is also an element of Y.
- X is greater than Y if Y is less than X.
- In all other cases X and Y are incomparable.
In other words: X is less than Y if and only if X is a proper subset of Y. Two sets are incomparable if neither is a subset of the other.
You are given two
(The string "LESS" means that X is less than Y, the string "GREATER" means that X is greater than Y. Quotes are for clarity only. Note that the return value is case-sensitive.)
Definition
- Class:
- SetPartialOrder
- Method:
- compareSets
- Parameters:
- int[], int[]
- Returns:
- String
- Method signature:
- String compareSets(int[] a, int[] b)
- (be sure your method is public)
Constraints
- Each of arrays a and b will have length between 1 and 50, inclusive.
- Each element of arrays a and b will be between 1 and 100, inclusive.
- In each of arrays a and b all elements are distinct.
Examples
{1, 2, 3, 5, 8}
{8, 5, 1, 3, 2}
Returns: "EQUAL"
The order of elements in a and b does not matter. The two sets X and Y are equal.
{2, 3, 5, 7}
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Returns: "LESS"
Each number that occurs in a does also occur in b.
{2, 4, 6, 8, 10, 12, 14, 16}
{2, 4, 8, 16}
Returns: "GREATER"
{42, 23, 17}
{15, 23, 31}
Returns: "INCOMPARABLE"
{1}
{1}
Returns: "EQUAL"
{5}
{4}
Returns: "INCOMPARABLE"
{100}
{95}
Returns: "INCOMPARABLE"
{4, 5, 6}
{9, 1, 4}
Returns: "INCOMPARABLE"
{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98}
{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98}
Returns: "EQUAL"
{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98}
{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99}
Returns: "INCOMPARABLE"
{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99}'
{51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99}
Returns: "INCOMPARABLE"
{1 }
{2, 3, 4 }
Returns: "INCOMPARABLE"
{1, 2, 3 }
{1, 4, 5, 6 }
Returns: "INCOMPARABLE"
{2, 3 }
{4, 1 }
Returns: "INCOMPARABLE"
{42, 23, 17, 50 }
{15, 23, 31 }
Returns: "INCOMPARABLE"
{1, 2, 3, 5, 8 }
{1 }
Returns: "GREATER"
{1, 2 }
{2, 3, 4 }
Returns: "INCOMPARABLE"
{3, 4, 5 }
{1, 2 }
Returns: "INCOMPARABLE"
{1, 2, 3, 5, 8 }
{8, 5, 1, 3, 2 }
Returns: "EQUAL"
{1, 2 }
{1, 2 }
Returns: "EQUAL"
{2, 3, 5, 15 }
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Returns: "INCOMPARABLE"
{2, 4, 6, 8, 10, 12, 14, 16 }
{2, 4, 8, 16 }
Returns: "GREATER"
{2, 3, 5, 7 }
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Returns: "LESS"
{1, 2, 4, 7, 8 }
{1, 4, 3 }
Returns: "INCOMPARABLE"
{100, 99 }
{99, 88 }
Returns: "INCOMPARABLE"
{1, 2, 3, 4, 5, 6, 7, 8 }
{13 }
Returns: "INCOMPARABLE"
{1, 2, 3 }
{1, 2 }
Returns: "GREATER"
{1, 2, 3 }
{4, 5 }
Returns: "INCOMPARABLE"
{1, 2, 3, 5, 8, 100 }
{8, 5, 1, 3, 2, 100, 99 }
Returns: "LESS"
{1, 100 }
{8, 5, 1, 3, 2 }
Returns: "INCOMPARABLE"
{1, 2, 3, 7, 6, 9 }
{8, 5, 1, 3, 2 }
Returns: "INCOMPARABLE"
{1, 2, 3, 5 }
{2, 4, 8, 9, 11 }
Returns: "INCOMPARABLE"
{2, 3, 4, 5, 6, 7, 8 }
{13 }
Returns: "INCOMPARABLE"
{1, 3, 4 }
{1, 2 }
Returns: "INCOMPARABLE"
{1, 2 }
{3 }
Returns: "INCOMPARABLE"
{2, 4, 6, 8 }
{2, 4, 6 }
Returns: "GREATER"
{42, 23, 17 }
{15, 23, 31 }
Returns: "INCOMPARABLE"