Back to problems

Jump Game Prime

Algorithm · Uber · Medium

You are given a 0-indexed integer array nums of length n. You begin at index 0. On each move you may advance in one of two ways: Jump forward by exactly 1 step. Jump forward by exactly p steps, where p is any prime number whose last digit is 3 (e.g., 3, 13, 23, 43, …). Whenever you land on an index—including the starting index 0 and the final index n - 1—you collect the value stored at that position. Return the maximum total sum you can collect over any valid sequence of…

Checking your access…