Company: UIDAI_16dec
Difficulty: medium
The best subsequence body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; line-height: 1.6; color: #333; max-width: 800px; margin: 20px auto; padding: 0 20px; } h1, h2, h3 { border-bottom: 1px solid #eee; padding-bottom: 10px; } code { background-color: #f4f4f4; padding: 2px 6px; border-radius: 4px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; } pre { background-color: #f4f4f4; padding: 15px; border-radius: 5px; overflow-x: auto; } ul { padding-left: 20px; } The best subsequence Description You are given an array a of size n and an integer k . The special value of a subsequence p is equal to Σ k i=2 |p i - p i-1 |, where p i denotes the i th element of the subsequence p . Find the minimum special value among all subsequences of array a that have a length of k . If it is not possible to apply the operations (e.g., if k ), the s