opt: findClosestNumber

Closes #120

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-08 20:08:49 +08:00
parent 89050c7ca8
commit 0eac1b2c69

View File

@@ -798,6 +798,9 @@ class Utils {
0 => target,
1 => numbers.first,
_ => numbers.reduce((a, b) {
if (b > target) {
return a;
}
int diff1 = (a - target).abs();
int diff2 = (b - target).abs();
return diff1 == diff2