We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0a51008 commit e1a1fb4Copy full SHA for e1a1fb4
src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
@@ -21,10 +21,14 @@ public static int getLongestArithmeticSubsequenceLength(int[] nums) {
21
if (nums == null) {
22
throw new IllegalArgumentException("Input array cannot be null");
23
}
24
-
+
25
// If the array is empty or has only one element, return its length.
26
- if (nums.length == 1 || nums.length == 0) {
27
- return nums.length;
+ if (nums.length == 0) {
+ return 0;
28
+ }
29
30
+ if (nums.length == 1){
31
+ return 1;
32
33
34
HashMap<Integer, Integer>[] dp = new HashMap[nums.length];
0 commit comments