Pairs with sum solution (t16x24) #2.

master
Tomasz Polgrabia 2025-01-03 13:52:07 +01:00
parent 5650e1ee69
commit a8177bcc59
1 changed files with 4 additions and 8 deletions

View File

@ -19,14 +19,10 @@ public class Solver {
if (nr > el) { if (nr > el) {
continue; continue;
} }
if (el != nr) { int existing_count = s.getOrDefault(nr, 0);
if (s.getOrDefault(nr, 0) < 1) { int required_count = el == nr ? 2 : 1;
continue; if (required_count > existing_count) {
} continue;
} else {
if (s.getOrDefault(nr, 0) <= 1) {
continue;
}
} }
solutions.add(new Solution(nr, el)); solutions.add(new Solution(nr, el));
} }