We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7eea9a5 commit 00ba70aCopy full SHA for 00ba70a
src/main/java/com/thealgorithms/searches/LinearSearch.java
@@ -46,11 +46,11 @@ public class LinearSearch implements SearchAlgorithm {
46
@Override
47
public <T extends Comparable<T>> int find(T[] array, T value) {
48
49
- if (array == null || array.length == 0 || value == null) {
+ if (array == null || value == null) {
50
return -1;
51
}
52
53
- for (int i = 0; i < array.length; i++) {
+ for (int i = 0, n = < array.length; i < n; i++) {
54
if (array[i] != null && array[i].compareTo(value) == 0) {
55
return i;
56
0 commit comments