Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What would be time complexity of below problem? class Solution { public: bool isValid ( vector& weights, int days , int mid ) { int
What would be time complexity of below problem?
class Solution
public:
bool isValidvector& weights, int days int mid
int d sum ;
for int i ; i weights.size ; i
if sum weightsi mid
sum weightsi ;
else
d;
sum weightsi;
if d days weightsi mid return false ;
return true ;
int shipWithinDaysvector& weights, int days
int start end mid answer ;
for int i ; i weights.size ; i
end weightsi ;
while start end
mid start end start ;
ifisValid weights days mid
answer mid ;
end mid ;
else
start mid ;
return answer ;
;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started