# Sajar Rajak
# Question 1: Js problem
```javascript=
const arrObj = [
{ age: 9, class: 6, name: 'A'},
{ age: 10, class: 5, name: 'B'},
{ age: 11, class: 6, name: 'C'},
{ age: 10, class: 5, name: 'D'},
{ age: 12, class: 6, name: 'E'},
{ age: 10, class: 5, name: 'F'},
{ age: 12, class: 7, name: 'G'},
]
const result = {
5: {
10: ['B', 'D', 'F']
},
6: {
9: ['A'],
11: ['C'],
12: ['E']
},
7: {
12: ['G']
}
}
let result = {};
arrobj.forEach((obj) => {
if (!result[obj['class']]) {
result[obj['class']] = {};
}
let classObj = result[obj['class']];
if (!classObj[obj['age']]) {
classObj[obj['age']] = [];
}
let ageObj = classObj[obj['age']];
ageObj.push(obj['name']);
});
console.log(result);
```
# Question 2:
weights = [1, 2, 3, 4, 2, 3, 1, 2, 3, 1, 2, 3, 4]
visited = [0, 1, 0, 1, 1]
maxWeight <= 6
Ex- 2
[3, 3, 3, 2, 2, 2]
maxSum = 6
# Question 3: Find the max sum in an integer array.
[1, 2, 3, 4, 5] - 1, 3, 5 = 9
[1, 2,-3, 4, 5] - 2, 5 = 7
const rec = (i, arr) => {
if (i >= arr.length) return 0;
return max(arr[i] + rec(i+2), rec(i+1));
}
-every number picked at ith index , cannot pick i-1th index i+1th index.
# DB Design:
- User Service already there.
Task Service
- Create a task (subtask), description, files, createdAt, updatedAt
- Assign the task to users. (Many to many)
- Track the status of assigned task/subtask (ENUM - completed, pending, started)
TaskUserRelation
| status | taskId | userId |
| --- | ------ | ------ |
| | Text | Text |
SubTaskUserRealtion
| status | subtaskId | userId |
| --- | ------ | ------ |
| | Text | Text |
Task
(PK) (FK)
| createdAt | updatedAt | description | TaskId |
| --------- | --------- | ----------- | --- --- | - | --- --- |
| Text | Text | Text | | | |
SubTask
(PK) (FK)
| createdAt | updatedAt | description | subTaskId | parentTaskIt | taskStatus |
| --------- | --------- | ----------- | --- --- | --- --- --- | --- --- |
| Text | Text | Text | | | |
T1, s1, s2, s3
U1, U2, U3
U2, s3 -
U3, s3 -