Description
Solutions
Submission
Maximum Information
🔥 FULLTIME

There is a computer network consisting of n servers, or nodes, numbered from 1 to n, and each node has a security value security_val[i]. A hacker must choose a starting node, start jumping through the network compromising servers along the way until reaching the end. From node x, the hacker can jump to node (x + K). If node (x + K) does not exist, the jump is out of the network and the hack ends. Initially, the hacker has access to 0 servers with 0 security value. The security value at each compromised node is added to the hacker's security value sum, and values may be negative.

The task is to choose the starting node optimally such that the hacker compromises servers with the maximum possible security value sum.

Example 1:

Input:  security_val = [2, -3, 4, 6, 1], k = 2
Output: 7
Explanation:
The security value sum is security_val[1] + security_val[3] + security_val[5] = 2 + 4 + 1 = 7.
Constraints:
    N/A
Thumbnail 0
Testcase

Result
Case 1

input:

output: