Skip to content

Commit 44d6591

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 68211ca commit 44d6591

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dynamic_programming/longest_arithmetic_subsequence.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import List
2+
23
"""
34
Longest Arithmetic Subsequence Problem: Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.
45
@@ -8,6 +9,7 @@
89
- A sequence seq is arithmetic if seq[i + 1] - seq[i] are all the same value (for 0 <= i < seq.length - 1).
910
"""
1011

12+
1113
def longest_arithmetic_subsequence(nums: List[int]) -> int:
1214
"""
1315
Finds the length of the longest arithmetic subsequence in a given array of integers.
@@ -39,7 +41,7 @@ def longest_arithmetic_subsequence(nums: List[int]) -> int:
3941
"""
4042
if nums is None:
4143
raise ValueError("Input array cannot be None")
42-
44+
4345
if len(nums) <= 1:
4446
return len(nums)
4547

@@ -57,6 +59,7 @@ def longest_arithmetic_subsequence(nums: List[int]) -> int:
5759

5860
if __name__ == "__main__":
5961
import doctest
62+
6063
doctest.testmod()
6164
# sample test case
6265
nums = [3, 6, 9, 12]

0 commit comments

Comments
 (0)