File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed
main/java/com/thealgorithms/datastructures/stacks
test/java/com/thealgorithms/stacks Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 33import java .util .Stack ;
44
55/**
6- * The {@code NearestElement} class provides static utility methods to find the nearest greater or smaller elements
7- * to the left or right of each element in an integer array using stack-based algorithms.
6+ * The {@code NearestElement} class provides static utility methods to find the
7+ * nearest greater or smaller elements to the left or right of each element in
8+ * an integer array using stack-based algorithms.
89 *
9- * <p>Each method runs in O(n) time complexity by maintaining a monotonic stack:
10+ * <p>
11+ * Each method runs in O(n) time complexity by maintaining a monotonic stack:
1012 * <ul>
11- * <li>{@code nearestGreaterToRight}: Finds the nearest greater element to the right of each element.</li>
12- * <li>{@code nearestGreaterToLeft}: Finds the nearest greater element to the left of each element.</li>
13- * <li>{@code nearestSmallerToRight}: Finds the nearest smaller element to the right of each element.</li>
14- * <li>{@code nearestSmallerToLeft}: Finds the nearest smaller element to the left of each element.</li>
13+ * <li>{@code nearestGreaterToRight}: Finds the nearest greater element to the
14+ * right of each element.</li>
15+ * <li>{@code nearestGreaterToLeft}: Finds the nearest greater element to the
16+ * left of each element.</li>
17+ * <li>{@code nearestSmallerToRight}: Finds the nearest smaller element to the
18+ * right of each element.</li>
19+ * <li>{@code nearestSmallerToLeft}: Finds the nearest smaller element to the
20+ * left of each element.</li>
1521 * </ul>
1622 */
1723public final class NearestElement {
Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ void testNearestSmallerToLeft() {
4848
4949 @ Test
5050 void testPrivateConstructor () throws Exception {
51- Constructor <NearestElement > constructor =
52- NearestElement .class .getDeclaredConstructor ();
51+ Constructor <NearestElement > constructor
52+ = NearestElement .class .getDeclaredConstructor ();
5353 constructor .setAccessible (true );
5454 try {
5555 constructor .newInstance ();
You can’t perform that action at this time.
0 commit comments