Here's a question but i have no idea

The question is "Given an integer m, we consider a sequence (with at least 2 elements) as beautiful if it contains 2 neighbors with difference no larger than m. Given an integer sequence with n elements, your job is to calculate the number of beautiful subsequences in it."
It's clear that I should use dynamic programming, but I have no idea about how to design it, can anyone give me some insructions ? Code is not needed.

Comments (0)