DhruvSaraswat

Hevo_Data_Round_1_Interview_LLD_30th_Sept_2026_Problem_Statement

Oct 6th, 2026
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | Source Code | 0 0
  1. Copy-pasted from https://gist.github.com/sharath-c-s/7f3cfb34de5507a319e2430a5a62e722
  2.  
  3. Calendar Application — Machine Coding Round
  4. Question
  5. Develop a calendar application that allows users to schedule events, handle overlapping meetings, register users with roles, and prioritize events based on role hierarchy when conflicts arise.
  6.  
  7. No CLI / input parser is required. Drive all operations through hardcoded test cases inside main() (or a test class). Focus time on modelling, correctness, and clean separation of concerns.
  8.  
  9. Operations
  10. Register user with role — role is one of VP, Director, Manager, Dev.
  11. Login (set current user) — subsequent schedule calls treat the logged-in user as the organizer.
  12. Schedule event — provide an event name, a start time, an end time, and a list of attendee user IDs.
  13. List events — for the currently logged-in user, list the events visible in their calendar after applying the conflict-resolution rules below.
  14. Role Hierarchy
  15. VP > Director > Manager > Dev
  16. Used only to break ties when two overlapping events compete for a slot in a user's calendar.
  17.  
  18. Constraints
  19. Single-day window. All events live inside one 24-hour day, in the range [0000, 2400). An event must satisfy 0000 <= startTime < endTime <= 2400. No event overflows into the next day.
  20. At most two events may overlap at any point inside a single user's calendar (raw, before conflict resolution). A schedule call that would cause a third concurrent event for any attendee (including the organizer) must be rejected with an exception. This is enforced at schedule time, not at list time.
  21. Conflict resolution is exhaustive. When two events overlap in a user's calendar, exactly one of the following two rules picks the winner — no other tiebreak is required, and the test data is designed so that no other tiebreak is ever needed:
  22. A self-scheduled event (where the user is the organizer) beats an event the user was invited to.
  23. Otherwise, the event whose organizer has the higher role wins. The losing event is hidden from that user's list output (it still exists on the organizer's calendar and on other attendees' calendars where it may win or lose independently).
  24. Times are integers in HHMM 24-hour form — e.g. 1400, 1530, 1730. End time is exclusive: an event 1400–1500 does not overlap an event 1500–1600.
  25. No CLI parsing. Wire the test cases directly in main() or a JUnit test. Don't spend time on tokenization or stdin handling.
  26. Overlap Definition
  27. Two events [s1, e1) and [s2, e2) overlap iff s1 < e2 && s2 < e1. Touching boundaries (e1 == s2) do not overlap.
  28.  
  29. Expectations
  30. Working, demo-able code (mandatory).
  31. Functionally correct against the supplied test cases (mandatory).
  32. Proper abstraction, entity modelling, and separation of concerns.
  33. Modular, readable, unit-testable code.
  34. Easy to extend for new requirements with minimal churn.
  35. Proper exception handling for: unknown user, invalid time range, day-overflow, more-than-two overlap, scheduling without a logged-in user.
  36. Bonus
  37. Edit / delete event.
  38. Meeting rooms attached to events; accept or decline if the room is unavailable.
  39. Concurrency safety (e.g., two schedulers racing on the same attendee's calendar).
  40. Test Cases
  41. Note: events with attendees listed include the organizer's own calendar implicitly — the organizer always sees their own event as a self-scheduled entry, no matter what is passed in attendees.
  42.  
  43. 1. Register users
  44. register u1, Dev
  45. register u2, Dev
  46. register u3, Manager
  47. register u4, VP
  48. register u5, Director
  49. 2. Schedule events (in order)
  50. login u2
  51. schedule e1, 1400 1500, attendees=[u1, u3, u4]
  52.  
  53. login u5
  54. schedule e2, 1300 1430, attendees=[u3]
  55.  
  56. login u4
  57. schedule e3, 1500 1700, attendees=[u2, u3]
  58.  
  59. login u3
  60. schedule e4, 1600 1730, attendees=[u1]
  61. 3. Rejected schedule — exceeds two-event overlap
  62. login u1
  63. schedule e5, 1410 1420, attendees=[u3]
  64. u3's raw calendar already holds e1 (1400–1500) and e2 (1300–1430) during 1410–1420. Adding e5 would push the overlap count to 3, which violates constraint 2.
  65.  
  66. Expected: schedule call throws OverlapLimitExceededException (or equivalent). e5 is not added to anyone's calendar.
  67.  
  68. 4. List events per user
  69. login u3
  70. list
  71. Expected output: e2, e4
  72.  
  73. Pair Window Resolution
  74. e1 (u2/Dev) vs e2 (u5/Director) 1400–1430 u3 not self → higher role wins → e2 keeps slot, e1 dropped from u3
  75. e3 (u4/VP) vs e4 (u3/self) 1600–1700 self wins → e4 keeps slot, e3 dropped from u3
  76. login u2
  77. list
  78. Expected output: e1, e3 — e1 is self, e3 is an invite from u4 (VP). They touch at 1500 but do not overlap.
  79.  
  80. login u4
  81. list
  82. Expected output: e1, e3 — e1 is an invite from u2 (Dev), e3 is self. No overlap.
  83.  
  84. login u1
  85. list
  86. Expected output: e1, e4 — both invites, no overlap (e1 ends 1500, e4 starts 1600).
  87.  
  88. login u5
  89. list
  90. Expected output: e2 — only self.
Advertisement
Add Comment
Please, Sign In to add comment