Interview
Interview
3 2
6 7 8 1
21 5
4 3 ans 4min
Given an array ‘arr’ of integer numbers, ‘arr[i]’ represents the number of pages in the ‘i-th’ book.
There are ‘m’ number of students, and the task is to allocate all the books to the students.
You have to allocate the book to ‘m’ students such that the maximum number of pages assigned
to a student is minimum.
Output: 113
1
2 5
4 3
vector<int> Bfs( Node V , vector <int> adj []){
Int n = adj.size();
int vis [n] = {0} ;
Queue <int> q;
q.push(V);
Vis [ V ] = 1;
Vector <int> bfs;
while(!q.empty()){
Int node = q.front();
q.pop();
bfs.push_back(node);
Return bfs;
vector<int> breathFirstSearch(Node* v,vector<int> &adj[]){
int n = adj.size();
vector<int> ans;
while(!nodes.empty()){
int node = nodes.front();
ans.push_back(node);
for(auto it:ad[node]){
if(!visit[it]){
visit[it]=1;
nodes.push(it);
}
}
}
return ans;
}