mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-19 04:07:36 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
68211cac0e
commit
44d6591236
@ -1,4 +1,5 @@
|
|||||||
from typing import List
|
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,6 +9,7 @@ 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.
|
||||||
@ -57,6 +59,7 @@ def longest_arithmetic_subsequence(nums: List[int]) -> int:
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import doctest
|
import doctest
|
||||||
|
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
# sample test case
|
# sample test case
|
||||||
nums = [3, 6, 9, 12]
|
nums = [3, 6, 9, 12]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user