mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-15 02:07:36 +00:00
ruff check fixes
This commit is contained in:
parent
68211cac0e
commit
92d21729a2
@ -1,4 +1,3 @@
|
|||||||
from typing import List
|
|
||||||
"""
|
"""
|
||||||
Longest Arithmetic Subsequence Problem: Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.
|
Longest Arithmetic Subsequence Problem: Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.
|
||||||
|
|
||||||
@ -8,13 +7,13 @@ Note that:
|
|||||||
- A sequence seq is arithmetic if seq[i + 1] - seq[i] are all the same value (for 0 <= i < seq.length - 1).
|
- A sequence seq is arithmetic if seq[i + 1] - seq[i] are all the same value (for 0 <= i < seq.length - 1).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def longest_arithmetic_subsequence(nums: List[int]) -> int:
|
def longest_arithmetic_subsequence(nums: list[int]) -> int:
|
||||||
"""
|
"""
|
||||||
Finds the length of the longest arithmetic subsequence in a given array of integers.
|
Finds the length of the longest arithmetic subsequence in a given array of integers.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
nums : List[int]
|
nums : list[int]
|
||||||
The input array of integers.
|
The input array of integers.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
@ -40,8 +39,11 @@ def longest_arithmetic_subsequence(nums: List[int]) -> int:
|
|||||||
if nums is None:
|
if nums is None:
|
||||||
raise ValueError("Input array cannot be None")
|
raise ValueError("Input array cannot be None")
|
||||||
|
|
||||||
if len(nums) <= 1:
|
if len(nums) == 0:
|
||||||
return len(nums)
|
return 0
|
||||||
|
|
||||||
|
if len(nums) == 1:
|
||||||
|
return 1
|
||||||
|
|
||||||
dp = [{} for _ in range(len(nums))]
|
dp = [{} for _ in range(len(nums))]
|
||||||
max_length = 2
|
max_length = 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user