PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates frontend UI engineering skills, focusing on interactive interface construction, event handling, and state modeling to maintain a single source of truth for events in a weekly calendar grid, and it belongs to the web frontend development and UI/state-management domain.

  • medium
  • Robinhood
  • Coding & Algorithms
  • Frontend Engineer

Build a Weekly Calendar

Company: Robinhood

Role: Frontend Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Implement an interactive weekly calendar UI. Requirements: - Display a one-week calendar with 7 days. - The calendar should be divided into 1-hour time slots. - Each visible cell represents a specific day and hour. - When the user clicks a cell, open a dialog that allows the user to enter an event name. - After the user submits the dialog, show the event in the corresponding calendar cell. - The implementation should manage state cleanly and avoid having multiple conflicting sources of truth. For example, store the canonical event data and derive any grid representation from it as needed. Assume a mockup is provided during the interview. Focus on building the core interaction and state model.

Quick Answer: This question evaluates frontend UI engineering skills, focusing on interactive interface construction, event handling, and state modeling to maintain a single source of truth for events in a weekly calendar grid, and it belongs to the web frontend development and UI/state-management domain.

You are implementing the state layer behind an interactive weekly calendar UI. The calendar has 7 days indexed from 0 to 6 and 24 one-hour slots indexed from 0 to 23. Each cell can hold at most one event name. Process a list of user actions: - ("click", day, hour): select a cell if the coordinates are valid. - ("submit", name): if a cell is currently selected, store name in that cell, replacing any existing event there. If name is an empty string, remove any event from that cell instead. Additional rules: - If a click is invalid (day not in 0..6 or hour not in 0..23), ignore it and keep the current selection unchanged. - If submit is called when no cell is selected, ignore it. - After any submit that uses a selected cell, clear the selection. Return the final canonical event data as a list of (day, hour, name) tuples sorted by day, then hour. A rendering layer can derive the visible 7x24 grid from this single source of truth.

Constraints

  • 0 <= len(actions) <= 100000
  • Valid day values are 0 through 6
  • Valid hour values are 0 through 23
  • Event names are strings and may be empty; an empty name clears the selected cell
  • At most 168 cells can contain events at any time

Examples

Input: []

Expected Output: []

Explanation: No actions means no events are stored.

Input: [("click", 0, 9), ("submit", "Standup"), ("click", 2, 14), ("submit", "Review")]

Expected Output: [(0, 9, 'Standup'), (2, 14, 'Review')]

Explanation: Two valid click-submit pairs create two events in different cells.

Input: [("submit", "Oops"), ("click", 6, 23), ("submit", "Deploy"), ("click", 6, 23), ("submit", "Hotfix")]

Expected Output: [(6, 23, 'Hotfix')]

Explanation: The first submit is ignored because nothing is selected. The later submit to the same cell overwrites the previous event.

Input: [("click", 1, 10), ("click", 7, 5), ("submit", "Sync")]

Expected Output: [(1, 10, 'Sync')]

Explanation: The second click is invalid, so the previous valid selection remains active and the submit applies to day 1, hour 10.

Input: [("click", 3, 8), ("submit", "Gym"), ("click", 3, 8), ("submit", ""), ("click", 3, 9), ("submit", "Read")]

Expected Output: [(3, 9, 'Read')]

Explanation: Submitting an empty string clears the event at day 3, hour 8. A new event is then added at day 3, hour 9.

Hints

  1. Use a hash map keyed by (day, hour) so each calendar cell has a single canonical event entry.
  2. Track the currently selected cell separately, and only build the sorted output after all actions are processed.
Last updated: May 12, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Solve path and inventory problems - Robinhood
  • Implement Calendar Layout and String Packing - Robinhood (medium)
  • Aggregate user logs into 30-minute sessions - Robinhood (hard)
  • Count Referral Descendants - Robinhood (medium)
  • Compute dependency load factors in a DAG - Robinhood (medium)