TikTok is selecting promotional placements from a sequence of eligible slots. Each slot has a nonnegative reward, but selecting two adjacent slots would create an unacceptable user experience, so adjacent slots cannot both be selected.
Given an integer array rewards, return the maximum total reward obtainable by selecting a subset of nonadjacent slots. You may select no slots.
rewards, a list of nonnegative integers, where rewards[i] is the reward for slot i.max_non_adjacent_reward(rewards).def max_non_adjacent_reward(rewards):