Arithmetic Slices II - Subsequence - Practice Coding | SlaveCode
0
0123456789
0
0123456789
:
0
0123456789
0
0123456789
446. Arithmetic Slices II - Subsequence
Hard
50 Points
Array
Dynamic Programming
Given an integer array nums, return the number of all the arithmetic subsequences of nums.
A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.
A subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.
The test cases are generated so that the answer fits in 32-bit integer.
Input: nums = [7,7,7,7,7]
Output: 16
Explanation: Any subsequence of this array is arithmetic.
Constraints
1 <= nums.length <= 1000
-231 <= nums[i] <= 231 - 1
446. Arithmetic Slices II - Subsequence
Hard
50 Points
Array
Dynamic Programming
Given an integer array nums, return the number of all the arithmetic subsequences of nums.
A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.
A subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.
The test cases are generated so that the answer fits in 32-bit integer.