Skip to content

Commit 85a850b

Browse files
tejaswi0910vil02
andauthored
Update src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
Co-authored-by: Piotr Idzik <[email protected]>
1 parent 677bbad commit 85a850b

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ public static int getLongestArithmeticSubsequenceLength(int[] nums) {
2121
throw new IllegalArgumentException("Input array cannot be null");
2222
}
2323

24-
if (nums.length == 0) {
25-
return 0;
26-
}
27-
28-
if (nums.length == 1) {
29-
return 1;
24+
if (nums.length <= 1) {
25+
return nums.length;
3026
}
3127

3228
HashMap<Integer, Integer>[] dp = new HashMap[nums.length];

0 commit comments

Comments
 (0)