Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,362 views

For proper oa or interview experiences list of all top tech companies visit :

https://oa.desiqna.in

https://interview.desiqna.in

 

image

 

in Online Assessments by Expert (44,360 points) | 1,362 views

2 Answers

0 like 0 dislike
Best answer

Construction Management
A construction company is building a new neighborhood and they are currently working on design. Each house will be built using one of three main materials but not side-by-side hiuses can be made of same material. because each hose will be varying size and complexity,  the cost of materials for each house varies. Given the cost of using each material for each house. what is the minimum cost needed to complete te neighborhood?

 

by Expert (44,360 points)
0 like 0 dislike
Solution: 
int minCost(vector<vector<int>> cost){
	int result =0;
	int r = cost.size();
	for(int i=0; i<n; i++){
		cost[i][0] += min(cost[i-1][1], cost[i-1][2]);
		cost[i][1] += min(cost[i-1][0], cost[i-1][2]);
		cost[i][2] += min(cost[i-1][1], cost[i-1][0]);
	}
	result = min(min(cost[r-1][0], cost[r-1][1]),cost[r-1][2]);
	return result;
}
by Expert (44,360 points)