AlgoMaster Logo
AlgoMasterDesign Slide Deckeasy

Design Slide Deck

easy

Design a SlideDeck that creates, orders, and removes its own slides. Each slide belongs to one deck and carries both its heading and speaker notes.

The provided SlideDeck class supports these operations:

  • SlideDeck() creates an empty deck.
  • int addSlide(String heading) adds a slide to the end of the deck and returns its number, or -1 for an empty heading. Slides are numbered from 1.
  • boolean setNotes(int number, String notes) sets that slide's speaker notes and returns true. It returns false for an empty note or a number outside the deck.
  • String notesOf(int number) returns that slide's speaker notes, or "NO NOTES" if it has none or the number is outside the deck.
  • boolean removeSlide(int number) removes that slide and returns true, or returns false if the number is outside the deck. Every later slide moves up one position.
  • String[] outline() returns the slide headings in order.
  • int slideCount() returns how many slides the deck holds.

A slide number represents its current position, not a permanent id. After a removal, every later slide moves up one position while keeping its own heading and notes.

Your task is to implement the Slide class expected by the provided deck. Do not modify SlideDeck. A slide should store an immutable heading, start with no notes, and keep its notes as part of the same object.

Example 1:

Input:

Output:

Explanation: The deck creates two slides in order. Notes are stored on the first slide itself, so notesOf(1) returns them while the outline remains unchanged.

Example 2:

Input:

Output:

Explanation: Removing First shifts Second into position 1. Its n2 notes move with it because the heading and notes belong to the same slide object.

Constraints

  • 0 <= heading.length, notes.length <= 40
  • At most 20 slides in one deck.
  • At most 100 calls in total are made across all methods.

How the design is graded

needs 7/10 to pass
  • The deck creates and owns its slides

    Full marks when `addSlide` builds a `Slide` inside the deck from the heading it was given, and there is no way for code outside the deck to construct a slide or hand one in. Lose points heavily when `SlideDeck` is the only class and the headings live in a bare list of strings.

  • A slide carries its own notes

    Full marks when the notes are a field on the slide, so a slide keeps its notes when the slides around it are removed. Lose points heavily when the deck keeps notes in a second list indexed by slide number, because removing a slide then leaves every later slide holding the wrong notes.

  • Structure and naming

    Full marks when slide numbers are positions counted from `1` and close up after a removal, a slide with no notes reports `NO NOTES`, and an empty heading or a number outside the deck is refused. Lose points for printing to stdout.

Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.

Hints

Loading...
CallReturns
new SlideDeck()null
addSlide("Why this matters")1
addSlide("The plan")2
setNotes(1, "open with the demo")true
notesOf(1)"open with the demo"
outline()["Why this matters","The plan"]
slideCount()2

Two slides are added and the first gets speaker notes. The deck reports the outline in order and the notes come back from the slide that owns them.

Run checks these cases. Submit also runs a larger hidden set.