Slice | Machine Coding | SDE-2 | Interview Question

slice logo
slice
SDE-2
June 9, 202519 reads

Summary

This post details a 90-minute virtual machine coding interview round for an SDE-2 role at Slice, focusing on designing and implementing an expense sharing application.

Full Experience

Duration : 90 Mins Mode : Virtual Expecations : Disucss the Approach. Disucss which DB you will use & why. Fully Running Code passing test cases.

Design an expense sharing application An expense sharing application is where you can add your expenses and split it among different people. The app keeps balances between people as in who owes how much to whom

Functional Requirements: User: Each user should have a userId, name, email, mobile number. Expense: Could either be EQUAL, EXACT or PERCENT Users can add any amount, select any type of expense and split with any of the available users. The percent and amount provided could have decimals up to two decimal places. In case of percent, you need to verify if the total sum of percentage shares is 100 or not. In case of exact, you need to verify if the total sum of shares is equal to the total amount or not. The application should have a capability to show expenses for a single user as well as balances for everyone. When asked to show balances, the application should show balances of a user with all the users where there is a non-zero balance. The amount should be rounded off to two decimal places. Say if User1 paid 100 and the amount is split equally among 3 people. Assign 33.34 to the first person and 33.33 to others.

Queries

Add User: (Input Format): Add_User [Name] [Email] [PhoneNumber]

Add Equal Expense to User Account: (Input Format) : Add_Expense [ExpenseName] [totalAmount] [paidBy UserId] [createdBy UserId] [totalUsers] Equal [User 1 Id] [User 2 Id] ........[User totalUsers Id]

Add Exact Expense to User Account: (Input Format) : Add_Expense [ExpenseName] [totalAmount] [paidBy UserId] [createdBy UserId] [totalUsers] Exact [User 1 Id] [User 2 Id] ........[User totalUsers Id] [Amount Paid by User 1] [Amount Paid by User 2] ......

Add Percent Expense to User Account: (Input Format) : Add_Expense [ExpenseName] [totalAmount] [paidBy UserId] [createdBy UserId] [totalUsers] Percent [User 1 Id] [User 2 Id] ........[User totalUsers Id] [Percent Share by User 1] [Percent Share by User 2] .....

Show User Data: (Input Format) : Show_User_Data [UserId]

Show All User Data with Positive Due Balance: (Input Format) : Show_All_User_Balance

Show_User_Expense By A User (Input Format): Show_User_Expense [UserId]

Interview Questions (1)

Q1
Design an Expense Sharing Application
System DesignHard

An expense sharing application is where you can add your expenses and split it among different people. The app keeps balances between people as in who owes how much to whom.

Functional Requirements: User: Each user should have a userId, name, email, mobile number. Expense: Could either be EQUAL, EXACT or PERCENT Users can add any amount, select any type of expense and split with any of the available users. The percent and amount provided could have decimals up to two decimal places. In case of percent, you need to verify if the total sum of percentage shares is 100 or not. In case of exact, you need to verify if the total sum of shares is equal to the total amount or not. The application should have a capability to show expenses for a single user as well as balances for everyone. When asked to show balances, the application should show balances of a user with all the users where there is a non-zero balance. The amount should be rounded off to two decimal places. Say if User1 paid 100 and the amount is split equally among 3 people. Assign 33.34 to the first person and 33.33 to others.

Queries

Add User: (Input Format): Add_User [Name] [Email] [PhoneNumber]

Add Equal Expense to User Account: (Input Format) : Add_Expense [ExpenseName] [totalAmount] [paidBy UserId] [createdBy UserId] [totalUsers] Equal [User 1 Id] [User 2 Id] ........[User totalUsers Id]

Add Exact Expense to User Account: (Input Format) : Add_Expense [ExpenseName] [totalAmount] [paidBy UserId] [createdBy UserId] [totalUsers] Exact [User 1 Id] [User 2 Id] ........[User totalUsers Id] [Amount Paid by User 1] [Amount Paid by User 2] ......

Add Percent Expense to User Account: (Input Format) : Add_Expense [ExpenseName] [totalAmount] [paidBy UserId] [createdBy UserId] [totalUsers] Percent [User 1 Id] [User 2 Id] ........[User totalUsers Id] [Percent Share by User 1] [Percent Share by User 2] .....

Show User Data: (Input Format) : Show_User_Data [UserId]

Show All User Data with Positive Due Balance: (Input Format) : Show_All_User_Balance

Show_User_Expense By A User (Input Format): Show_User_Expense [UserId]

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!