Loading...
Loading...
A land office lists plots as l b. A 20 × 30 plot and a 30 × 20 plot are the same size, so Plot.equals() must treat them as equal, and hashCode() must agree: return Objects.hash(shorter side, longer side). Group the plots in a hash table with 8 buckets (Math.abs(hashCode() % 8)). Print each distinct size once, in first-seen order, with how many plots have it, then the number of distinct sizes in the fullest bucket.
<shorter> x <longer>: <count> per distinct size, then Fullest bucket: <k>.Example
Input
5 20 30 30 20 10 10 20 30 15 40
Output
20 x 30: 3 10 x 10: 1 15 x 40: 1 Fullest bucket: 1
30 × 20 is the same size as 20 × 30, so that size has 3 plots. Each size here sits alone in its bucket.
Try the problem first. Open one hint at a time.
Compare min(l, b) with the other plot's min, and max with max.
Equal plots must get equal hash codes, so hashCode() must also use the shorter and longer side, not l and b as typed.
Store indexes in the buckets and keep the distinct plots and their counts in arrays in first-seen order.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor