System design · LLD design
Splitwise
FR
1.User can create a group and add/remove participants
1.user can add a expenses between partiticants in a group or individual participant
2.user can split the amount based on split type selected so can be different types of split logic
3.on adding expenses , system compute all participants owe amount and update the balance between pair
4.Users can settle up — record a payment between two users, which updates their balance accordingly.
5.Users can view their net balance with a specific user, or a summary of all balances across users.
6.valided the split amount should be equal to the total
NFR
1.consistency : addition of expenses, should reflect for all the participants or neither
2.Concurrency : safely handle expenses addition and settlements that touch overlapping user
3.Extensible: system should be able to add new split logic
4.Scalable: support group of user , groups and expenses
Entities
User
-
I am preparing for Deshaw interview , which is in 8 days
The interview will focus on:
- Problem solving (data structures & algorithms)
- Programming language fundamentals
- Core CS fundamentals
for the Senior Member, Tech (All positions) role and i use java as my coding lanague
and honestly i am very week in Programming language fundamentals and core CS fundamentals
so provide me a proper plan for preparing these two like topic and where to study
and also provide me all the previously asked questions
and for Problem solving (data structures & algorithms) provide me all the previously asked questions
and topic wise revision questions
and go deeper to verify and check all concepts or questions asked in deshaw
provide me in a proper excel to track what what i have done
LinkedHashMap why need this in reposiroy
Leetcode Hackathon
Difficult : SMALL, HARD, MEDIUM
Problem
-problemId : String
-description : String
-score : int
-tags : Set<String>
-difficulty: DIFFICULTY
Contestant
-id : String
-name :String
-department: String
Submission
-contestantID : String
-problemId: String
-timeTakenSeconds: int
-solvedAt : Instant
-scoreAwarded : int
ContestantRepository interface
InMemoryContestantRepository - implement ContestantRepository
+save(contestant)
+getContestant(id)
+findAll()
InMemoryProblemRepository
+save(problem)
+findByID(problemID)
+findAll()
InMemorySubmissionRepository
+save(submission)
+findByContestantId(contestantId)
+findByProblemId(problemID)
+findAll()
ContestantService
-contestantRepository
-problemRepository
-submissionRepository
+addContestant(string name , String desc)
+fetchSolvedProblems(contestantID) : List<Problems>
ProblemService
-problemRepository
-submissionRepository
+addProblem()
+fetchProblemsOnFilter(filters, sort)
+getTopNProblems(tag, n)
+getProblemStrats(problemID) : ProblemStrats
ProblemStrats
-solveCount
-averageTimeTakeSeconds
SolveResult
-scoreAwarded: int
-recommendatedProblems : List<Problem>
ScoringStrategy interface
TimeAdjustedScoreStrategy - implement ScoringStrategy
+calculateScore(problem , timeTaken)
RecommendationStrategy interface
SimilarTagRecommendationStrategy - implement RecommendationStrategy
+recommended(problem , list<Problem> candidate, count) : List<Problem>
ContestService
-scoringStrategy
-submissionRepository
-contestantRepositiory
-problemRepository
+solve(contestantID, problemID, timeTaken) : SolveResult
Calc score awarded - using scoring strategy
Save submission
get recommended problems using recommendationStrategy
Create SolveResult
+getLeader()
Fetch from submssionrepo