← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given an integer array nums where nums[i] is the score at index i.
You start at index 0 and want to reach index n - 1. Every time you land on an index, you add that index's value to your total score. The starting index 0 counts as already landed on, so nums[0] is included in the total.
From index i, you may jump only to the right by:
1 step, orp steps where p is a prime number whose last digit is 3
Examples of allowed prime jumps include 3, 13, 23, and so on.
Return the maximum total score you can collect when you land on index n - 1.Jump directly from index 0 to index 3 using a 3-step jump. The score is nums[0] + nums[3] = 5 + 10 = 15.
A 13-step jump is allowed because 13 is prime and ends in 3. Jumping directly from 0 to 13 gives 4 + 20 = 24.