Skip to content

Commit 92d2172

Browse files
committed
ruff check fixes
1 parent 68211ca commit 92d2172

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

dynamic_programming/longest_arithmetic_subsequence.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from typing import List
21
"""
32
Longest Arithmetic Subsequence Problem: Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.
43
@@ -8,13 +7,13 @@
87
- A sequence seq is arithmetic if seq[i + 1] - seq[i] are all the same value (for 0 <= i < seq.length - 1).
98
"""
109

11-
def longest_arithmetic_subsequence(nums: List[int]) -> int:
10+
def longest_arithmetic_subsequence(nums: list[int]) -> int:
1211
"""
1312
Finds the length of the longest arithmetic subsequence in a given array of integers.
1413
1514
Parameters
1615
----------
17-
nums : List[int]
16+
nums : list[int]
1817
The input array of integers.
1918
2019
Returns
@@ -40,8 +39,11 @@ def longest_arithmetic_subsequence(nums: List[int]) -> int:
4039
if nums is None:
4140
raise ValueError("Input array cannot be None")
4241

43-
if len(nums) <= 1:
44-
return len(nums)
42+
if len(nums) == 0:
43+
return 0
44+
45+
if len(nums) == 1:
46+
return 1
4547

4648
dp = [{} for _ in range(len(nums))]
4749
max_length = 2

0 commit comments

Comments
 (0)