update README.md + update tests + add solution for hw2:3839
All checks were successful
Binary Search Test / test (push) Successful in 6s

This commit is contained in:
2026-02-17 13:47:22 +03:00
parent 31f56cd92d
commit bcb0f25a1d
5 changed files with 96 additions and 1 deletions

View File

@@ -37,11 +37,21 @@ public final class BinarySearchTest {
}
// === 3839
private static String span(final int c, final int x, final int[] a) {
final int begin = range(0, a.length).filter(i -> a[i] == x || Integer.compare(x, a[i]) == c).findFirst().orElse(a.length);
final long length = range(0, a.length).filter(i -> a[i] == x).count();
return begin + " " + length;
}
// === Common code
public static final Selector SELECTOR = new Selector(BinarySearchTest.class)
.variant("Base", Solver.variant0("", Kind.DESC, BinarySearchTest::base))
.variant("3637", Solver.variant0("3637", Kind.DESC, BinarySearchTest::count))
.variant("3839", Solver.variant0("3839", Kind.DESC, BinarySearchTest::span))
;
public static void main(final String... args) {