0
0
LLDsystem_design~20 mins

User, Group, Expense classes in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
UserGroupExpense Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the correct relationship between User, Group, and Expense classes

In a system where users can belong to groups and share expenses, which of the following best describes the relationship between User, Group, and Expense classes?

AUsers belong to a single Group only; Expenses belong to Users only; Groups do not track Expenses.
BA User can belong to multiple Groups; a Group contains multiple Users; an Expense is linked to a Group and paid by a User.
CAn Expense belongs to multiple Users; Groups are independent and do not contain Users; Users pay Expenses individually.
DA Group belongs to a single User; an Expense belongs to a User only; Users do not belong to Groups.
Attempts:
2 left
💡 Hint

Think about how users collaborate in groups and how expenses are shared.

Architecture
intermediate
1:30remaining
Choose the best class attribute to represent an Expense's payer

Which attribute best represents the payer of an Expense in the Expense class?

Apayer_group: stores the Group object that paid the expense.
Bpayer_name: stores the name of the User who paid the expense as a string.
Cpayer_id: stores the unique identifier of the User who paid the expense.
Dpayer_amount: stores the amount paid by the User.
Attempts:
2 left
💡 Hint

Consider how to uniquely identify the payer without duplicating user data.

scaling
advanced
2:30remaining
Scaling the Group class for thousands of Users

When a Group contains thousands of Users and hundreds of Expenses, which design choice helps maintain performance and scalability?

AStore only User IDs in the Group class and fetch User details on demand.
BStore User objects directly inside the Group class as a list.
CDuplicate User data inside each Group to avoid fetching from User class.
DStore Expense objects inside each User instead of the Group.
Attempts:
2 left
💡 Hint

Think about memory usage and data duplication when handling large numbers.

tradeoff
advanced
3:00remaining
Tradeoff between storing Expense split details in Expense vs User

Where should the details of how an Expense is split among Users be stored for best design?

AStore split details in a separate Split class linking Users and Expenses.
BStore split details inside each User class as a list of Expenses and amounts.
CStore split details inside the Expense class as a map of User IDs to amounts.
DDo not store split details; calculate splits dynamically each time.
Attempts:
2 left
💡 Hint

Consider separation of concerns and flexibility for future changes.

estimation
expert
3:00remaining
Estimate storage for 1 million Users, 100k Groups, and 10 million Expenses

Estimate the approximate storage needed if each User object requires 1KB, each Group object 2KB, and each Expense object 0.5KB. Ignore overhead and indexes.

AApproximately 8.5 GB
BApproximately 7.5 GB
CApproximately 5.5 GB
DApproximately 6.5 GB
Attempts:
2 left
💡 Hint

Calculate total size by multiplying counts by sizes and summing.