Build a Single-Day Calendar UI with Create, Edit and Delete for Hourly Events
Company: Ramp
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: hard
Interview Round: Technical Screen
In a technical phone screen of about 45 minutes, build a working single-day calendar as a small web app. The goal is functionality, not styling; you do not need to imitate the look of any existing calendar product.
**Layout**
- Today's date is shown at the top of the page.
- Below the date, a header holds three inputs (start time, end time and name) and a Save button. The header stays visible at all times.
- The day is shown as a single column of 24 one-hour blocks, with each hour's label to the left of its block.
- Each event is drawn as a rectangle that covers one or more hour blocks.
**Creating an event**
- Clicking an empty hour block fills the start-time input with that block's hour.
- Save creates the event from the inputs, shows it on the calendar, and clears the inputs.
**Editing and deleting**
- Clicking an existing event fills the header inputs with that event's start time, end time and name, so the inputs default to its current values.
- Clicking Save applies the edit and the calendar updates.
- While an existing event is being edited, there is a button to delete it. Deleting the event clears the inputs.
Event start and end times always fall exactly on the hour (for example 2 PM to 5 PM); times such as 2:03 to 5:07 do not need to be handled.
```hint Pick the state first
Decide what the single source of truth is: the list of events, the three input values, and whether you are creating a new event or editing a particular one. Most of the required behavior follows from that.
```
```hint Hours as numbers
With times stored as whole-hour numbers, an event's position and height in the column follow from simple arithmetic on its start and end.
```
### Constraints and Clarifications
- Representing times as numbers rather than date objects is likely to be easier.
- You may look up documentation, articles and code examples online.
- You may install and use libraries for data fetching, styling and state management.
- TypeScript is not required.
### Clarifying Questions
- Is an event's end hour exclusive, so that 2 PM to 5 PM covers the 2, 3 and 4 PM blocks? Can an event end at midnight?
- What should the end-time input default to when an empty block is clicked?
- May events overlap, and if so how should overlapping rectangles be drawn?
- What should Save do when the name is empty or the end is not after the start?
- After saving an edit, should the inputs clear and the header go back to creating a new event?
- Must events survive a page reload, or is in-memory state enough?
### What a Strong Answer Covers
- A clear state model separating the event list, the input values and the current edit selection, with stable event ids
- Create, edit, delete and clear flows that match every item in the specification, including the defaults filled in by clicks
- Events rendered as rectangles positioned and sized from whole-hour numbers, aligned with the 24 labeled blocks
- Input validation and a deliberate choice for overlapping events
- Interaction details such as a click on an event not also counting as a click on the empty block, and a header that stays visible while the day scrolls
- Runnable code delivered within the time box, with styling kept minimal
### Follow-up Questions
- How would you lay out several overlapping events so that none is hidden and events without overlaps keep their full width?
- How would you support events with minute precision, such as 2:03 to 5:07?
- How would you save events through a backend API and keep the interface responsive while requests are in flight or fail?
- How would you make the calendar usable with a keyboard and a screen reader?
Overview: Build a working single-day calendar web app in about 45 minutes, with 24 labeled hour blocks, events drawn as rectangles, and an always-visible header of start, end and name inputs for creating, editing and deleting events. It tests state modeling, event handling and shipping a functional UI under time pressure.
Read the full Ramp Software Engineer interview experience this question came from