FastPrepPizza Discount Days
Problems/Pizza Discount Days

Pizza Discount Days

Nutanix logoNutanix● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: One of the two questions in this Nutanix intern online assessment report is about buying pizzas with deals. A deal is one pizza on each of two days in a row, or two pizzas on the same day. The report gives no written task. It shows two sample inputs, each with a yes or no answer and a short note. These suggest the question asks whether every day's count can be met using the deals alone.

Here we chose the following. Each day must get exactly its count. Every pizza must come from a deal. A two-day deal may not start on the last day. The function returns true or false. There are 1 to 2000 days with 0 to 10^4 pizzas on each. The examples are new.

Our version is about 75% the same as the reported question.

A pizza shop has two deals. You may use each deal as many times as you like:

  • Two-day deal: buy one pizza on some day and one more pizza on the next day.
  • Same-day pair: buy two pizzas on the same day.

You are buying pizzas for n days in a row. On day i (counting from 0) you must buy exactly pizzas[i] pizzas, not more and not fewer. Every pizza you buy must come from one of the deals. A two-day deal cannot start on the last day, because there is no next day.

Return true if you can buy exactly the right number of pizzas on every day using only the deals, and false otherwise.

Function

canBuyWithDeals(pizzas: int[]) → boolean

Examples

Example 1

pizzas = [1,3,3,1]return = true

Start a two-day deal on day 0: one pizza on day 0 and one on day 1. Day 1 still needs 2, so buy one same-day pair. Day 2 needs 3: buy one same-day pair and start a two-day deal, which also gives day 3 its single pizza. Every day gets exactly its count, so the answer is true.

Example 2

pizzas = [3,0,1]return = false

Day 0 needs 3 pizzas. Same-day pairs give an even number, so day 0 must start at least one two-day deal. But each two-day deal started on day 0 also gives a pizza on day 1, and day 1 needs 0. So the answer is false.

Example 3

pizzas = [2,3]return = false

A two-day deal cannot start on day 1, the last day. So every deal puts exactly 2 pizzas into days 0 and 1 together: a pair on one day, or a two-day deal on days 0 and 1. The total of the two days is then always even, but 2 + 3 = 5 is odd. The answer is false.

Constraints

  • 1 <= pizzas.length <= 2000
  • 0 <= pizzas[i] <= 10^4

More Nutanix Online Assessment questions

  • Good SubsequencesOA · Seen Jul 2026
  • Min Cost to Connect All PointsOA · Seen Jun 2026
  • Digit Changes for a Multiple of 9OA · Seen Aug 2025
  • Gas Station Loop StartOA · Seen Aug 2025
  • Number of Players (for MTS2)OA · Seen Oct 2024
  • Work Schedules (for MTS2)OA · Seen Oct 2024
  • Minimum Operations to Convert ArrayOA · Seen Apr 2024
  • No Adjacent CharactersOA · Seen Apr 2024
  • Build a BST From a ListOA · Seen Nov 2022
  • Delete Even-Valued Nodes From a Linked ListOA · Seen Nov 2022

Similar questions at other companies

  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Server InvestmentRippling · OARippling interview questions
  • Book Reading EveningsGoogle · OAGoogle interview questions
  • Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
  • Minimum Project Bid CostNVIDIA · OANVIDIA interview questions
  • Minimum AmountBelvedere Trading · OA
  • Maximum Income from Asset TradingJefferies · OA
  • Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
  • Economical TripAccenture · OAAccenture interview questions
  • Best Time to Buy and Sell StockFlexTrade · OAFlexTrade interview questions

Interview reports that mention this question

  • Nutanix SWE Intern OA Questions: 16 Experiences (Part 2 of 3)

Nutanix interview experiences

  • Nutanix SWE Intern Phone Screens: 20 Experiences (Part 3 of 3)
  • Nutanix U.S. SWE Intern Interviews: 54 Experiences (Part 1 of 3)
  • Nutanix SWE OA and Interviews, Level Not Reported: 9 Experiences
  • Nutanix Intern Debugging Round and Interviews: 25 Experiences
All Nutanix interview questionsSee Nutanix hiring insights
Saved
class Solution {
    public boolean canBuyWithDeals(int[] pizzas) {
        // Write your code here.
    }
}
Checking account…