Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct Task {
- int taskId;
- string assigneeName;
- string reviewerName;
- string status;
- double estimateInHours;
- };
- vector<Task> assignReviewers(vector<Task>& tasks) {
- unordered_map<string,double>reviwerMap;
- for (const auto& task : tasks){
- if(task.status == "in-review" && task.reviewerName != "" || task.status == "done" && task.reviewerName != ""){
- reviwerMap[task.reviewerName] += (task.estimateInHours/3);
- }
- reviwerMap[task.assigneeName] += task.estimateInHours;
- }
- for(auto& task:tasks){
- if(task.status == "in-review" && task.reviewerName.empty()){
- double minimumEffortSpent = INT_MAX;
- string reviewer;
- for(const auto& [memberName, totalEffort] :reviwerMap){
- if(task.assigneeName != memberName && totalEffort < minimumEffortSpent){
- minimumEffortSpent = totalEffort;
- reviewer = memberName;
- }
- }
- task.reviewerName = reviewer;
- reviwerMap[reviewer] += (task.estimateInHours / 3);
- }
- }
- return tasks;
- }
- int main() {
- vector<Task> tasks = {
- {1, "John", "", "todo", 4},
- {2, "Jane", "Khaled", "in-review", 10},
- {3, "Jim", "John", "in-review", 9},
- {4, "Khaled", "", "in-review", 5},
- {5, "John", "", "in-review", 7},
- {6, "Khaled", "", "in-review", 12},
- {7, "Jim", "", "in-review", 3},
- {8, "Jane", "", "in-review", 8},
- {9, "Jane", "", "in-progress", 15},
- {10, "Tariq", "", "in-review", 13},
- {11, "Jane", "Tariq", "done", 8},
- };
- vector<Task> updatedTasks = assignReviewers(tasks);
- for (const auto& task : updatedTasks) {
- cout << "taskId: " << task.taskId << ", assigneeName: " << task.assigneeName << ", reviewerName: " << task.reviewerName << ", status: " << task.status << ", estimateInHours: " << task.estimateInHours << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement