Maximize Weekly Workout Calories Without Back-to-Back Intense Days

Last updated: November 29, 2026

Quick Overview

Fitness+ suggests an intense workout plan where day i would burn calories[i], but the user cannot do intense workouts on two consecutive days. Return the maximum total calories achievable.

Apple
Coding & Algorithms
Software Engineer
Apple
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Fitness+ suggests an intense workout plan where day i would burn calories[i], but the user cannot do intense workouts on two consecutive days. Return the maximum total calories achievable.

A gentle dynamic programming warm-up dressed in Apple Fitness+ terms, common in early screens. The interviewer checks that you define the state clearly and reduce space to O(1).

What the Interviewer Expects
  • Define the recurrence best[i] = max(best[i-1], best[i-2] + calories[i])
  • Handle zero, one and two days
  • Reduce to two rolling variables
  • Explain why greedy picking of the largest days fails
  • Optionally reconstruct which days were chosen
Key Topics to Cover
dynamic programming
1D DP
space optimization
recurrences
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Return the chosen days, not just the total.
  • The plan wraps around weekly, so day 7 and day 1 are also adjacent.
  • Allow at most two intense days in a row instead of one.
  • Some days are blocked by the user's calendar.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: list of non-negative ints calories. Output: maximum sum of a subset with no two adjacent indices. Empty list gives 0....

High-Level Design

Let take be the best total that includes the current day and skip the best total that excludes it. Moving to day i, the new take is skip + calories[i] and the new skip is max(take, skip). ...


Submit Your Answer
Markdown supported