Skip to content

Commit 5656637

Browse files
committed
Again Fixed formatting and Checkstyle issues
1 parent c2585ef commit 5656637

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/main/java/com/thealgorithms/datastructures/arrays/LeadersInArray.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.thealgorithms.datastructures.arrays;
22

33
/**
4-
* A program to find leaders in an array.
4+
* A utility class to find leaders in an array.
55
*
66
* <p>
7-
* A leader is an element that is greater than all the elements to its right.
7+
* A leader is an element greater than all elements to its right.
88
* The rightmost element is always a leader.
99
*
1010
* Time Complexity: O(n)
@@ -14,7 +14,7 @@
1414
*/
1515
public final class LeadersInArray {
1616

17-
// Prevent instantiation of this utility class
17+
// Private constructor to prevent instantiation
1818
private LeadersInArray() {
1919
}
2020

@@ -42,6 +42,7 @@ public static void findLeaders(final int[] arr) {
4242
*
4343
* @param args command line arguments (not used)
4444
*/
45+
@SuppressWarnings("PMD.UselessMainMethod")
4546
public static void main(final String[] args) {
4647
int[] arr = {16, 17, 4, 3, 5, 2};
4748
findLeaders(arr);

src/main/java/com/thealgorithms/datastructures/arrays/PeakElement.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
package com.thealgorithms.datastructures.arrays;
22

33
/**
4-
* A program to find a peak element in an array.
4+
* A utility class to find a peak element in an array.
55
*
66
* <p>
7-
* A peak element is an element that is greater than or equal to its neighbors.
8-
* For corner elements, only one neighbor is considered.
7+
* A peak element is an element greater than or equal to its neighbors.
98
*
10-
* Time Complexity: O(n)
9+
* Time Complexity: O(log n) using binary search
1110
* Space Complexity: O(1)
1211
*
1312
* Author: https://github.com/VeeruYadav45
1413
*/
1514
public final class PeakElement {
1615

17-
// Prevent instantiation of this utility class
16+
// Private constructor to prevent instantiation
1817
private PeakElement() {
1918
}
2019

2120
/**
22-
* Finds the index of any peak element in the array.
21+
* Finds the index of a peak element using binary search.
2322
*
2423
* @param arr the input array
2524
* @return the index of a peak element
@@ -54,6 +53,7 @@ public static int findPeakElement(final int[] arr) {
5453
*
5554
* @param args command line arguments (not used)
5655
*/
56+
@SuppressWarnings("PMD.UselessMainMethod")
5757
public static void main(final String[] args) {
5858
int[] arr = {1, 3, 20, 4, 1, 0};
5959
int peakIndex = findPeakElement(arr);

0 commit comments

Comments
 (0)